[phpBB Debug] PHP Warning: in file [ROOT]/phpbb/db/driver/mysqli.php on line 264: mysqli_fetch_assoc(): Couldn't fetch mysqli_result
[phpBB Debug] PHP Warning: in file [ROOT]/phpbb/db/driver/mysqli.php on line 326: mysqli_free_result(): Couldn't fetch mysqli_result
Pete's QBASIC Site Discuss QBasic, Freebasic, QB64 and more 2008-07-29T13:18:54-05:00 http://petesqbsite.com/phpBB3/app.php/feed/topic/2722 2008-07-29T13:18:54-05:00 2008-07-29T13:18:54-05:00 http://petesqbsite.com/phpBB3/viewtopic.php?p=17564#p17564 <![CDATA[Need help - Strange tile problem]]> Statistics: Posted by burger2227 — Tue Jul 29, 2008 1:18 pm


]]>
2008-07-29T09:10:06-05:00 2008-07-29T09:10:06-05:00 http://petesqbsite.com/phpBB3/viewtopic.php?p=17561#p17561 <![CDATA[Need help - Strange tile problem]]>
Mentat, you already gave a very good reason NOT to use the GOTO. You are spoiling that by adding trivial reasons, as UNTIL can be substituted - and this is what I have used for years - with a WHILE/WEND. Just let your first, convincing reason why not to use GOTOs in public stand as THE reason, since most, if not all, other "reasons" can be stepped around by existing other coding commands, statements, or methods.
Oh, sorry. I was just talking to TmEE about the difference between do/loop and while/wend.

Statistics: Posted by Mentat — Tue Jul 29, 2008 9:10 am


]]>
2008-07-29T08:38:25-05:00 2008-07-29T08:38:25-05:00 http://petesqbsite.com/phpBB3/viewtopic.php?p=17560#p17560 <![CDATA[Need help - Strange tile problem]]> Statistics: Posted by Ralph — Tue Jul 29, 2008 8:38 am


]]>
2008-07-29T07:03:13-05:00 2008-07-29T07:03:13-05:00 http://petesqbsite.com/phpBB3/viewtopic.php?p=17559#p17559 <![CDATA[Need help - Strange tile problem]]> Statistics: Posted by Mentat — Tue Jul 29, 2008 7:03 am


]]>
2008-07-29T04:44:40-05:00 2008-07-29T04:44:40-05:00 http://petesqbsite.com/phpBB3/viewtopic.php?p=17557#p17557 <![CDATA[Need help - Strange tile problem]]>

I myself use WHILE/WEND loops, I've used DO/LOOP only once... what's the difference between to two anyway ? Their purpose is same...

Statistics: Posted by TmEE — Tue Jul 29, 2008 4:44 am


]]>
2008-07-27T23:11:41-05:00 2008-07-27T23:11:41-05:00 http://petesqbsite.com/phpBB3/viewtopic.php?p=17554#p17554 <![CDATA[Need help - Strange tile problem]]>
Now, with my understanding that it's best not to show the new, future programmers how to make spagetti code, I am making it a point not to do so, and make the ?DO/LOOPs "second nature" to me.

Finally, after all this time, I got a very good and reasonable answer from Menat. In the past, I only saw flaming accusations if anyone used a GOTO, and conclusions that, if a programmer chose to use GOTO in a reasonable and easy-to-follow manner, it was alright. As I've said in this thread, Menat has given me the first GOOD reason for me to forget the use of GOTOs. Thanks again, Menat.

Statistics: Posted by Ralph — Sun Jul 27, 2008 11:11 pm


]]>
2008-07-27T15:32:31-05:00 2008-07-27T15:32:31-05:00 http://petesqbsite.com/phpBB3/viewtopic.php?p=17549#p17549 <![CDATA[SEE GOTO GO]]>
New programmers often get in a bad habit using GOTO. They don't even bother making loops. Troubleshooting the code often becomes a confusing Task.

GOTO is almost as useless as LET, but those are often the two first things that POOR teachers throw at them! I'm glad most of them are moving onto NET nowadays. They can screw that up all they want!

As you demonstrated Ralph, what was so hard about NOT using GOTO?

Ted

Statistics: Posted by burger2227 — Sun Jul 27, 2008 3:32 pm


]]>
2008-07-27T14:38:25-05:00 2008-07-27T14:38:25-05:00 http://petesqbsite.com/phpBB3/viewtopic.php?p=17547#p17547 <![CDATA[Need help - Strange tile problem]]>
Next up, generating animations on the fly. :mrgreen:

Statistics: Posted by Mentat — Sun Jul 27, 2008 2:38 pm


]]>
2008-07-27T14:19:54-05:00 2008-07-27T14:19:54-05:00 http://petesqbsite.com/phpBB3/viewtopic.php?p=17545#p17545 <![CDATA[Need help - Strange tile problem]]> After considering Mentat's postings, I have accepted eliminating GOTOs, and present the code with the necessary DO/LOOPs substituted.

Code:

'''July 28, 2008: Changed GOTOs to DO/LOOPs'''July 27, 2008: Changes or additions by Ralph are identified with three'apostrophes, as in  '''DIM grass(10, 10), path(10, 10), water(10, 10), tent(10, 10), scout(10, 10), scoutmask(10, 10)DIM oldscoutarea(10, 10), map(30, 15)'''SCREEN 13scoutx = 5scouty = 1FOR y = 1 TO 10FOR x = 1 TO 10READ clrIF clr = 1 THEN PSET (x, y), 10IF clr = 0 THEN PSET (x, y), 2NEXTNEXTGET (1, 1)-(10, 10), grassFOR y = 1 TO 10FOR x = 1 TO 10READ clrIF clr = 0 THEN PSET (x, y), 6IF clr = 1 THEN PSET (x, y), 14NEXTNEXTGET (1, 1)-(10, 10), pathFOR y = 1 TO 10FOR x = 1 TO 10READ clrIF clr = 0 THEN PSET (x, y), 3IF clr = 1 THEN PSET (x, y), 11NEXTNEXTGET (1, 1)-(10, 10), waterFOR y = 1 TO 10FOR x = 1 TO 10READ clrIF clr = 0 THEN PSET (x, y), 6IF clr = 1 THEN PSET (x, y), 8IF clr = 2 THEN PSET (x, y), 0NEXTNEXTGET (1, 1)-(10, 10), tentFOR y = 1 TO 10FOR x = 1 TO 10READ clrIF clr = 0 THEN PSET (x, y), 0IF clr = 1 THEN PSET (x, y), 5 '''was 2IF clr = 2 THEN PSET (x, y), 8IF clr = 3 THEN PSET (x, y), 14IF clr = 4 THEN PSET (x, y), 4NEXTNEXTGET (1, 1)-(10, 10), scoutFOR y = 1 TO 10  FOR x = 1 TO 10    READ clr    IF clr = 0 THEN PSET (x, y), 255    IF clr = 1 THEN PSET (x, y), 2    IF clr = 2 THEN PSET (x, y), 8    IF clr = 3 THEN PSET (x, y), 14    IF clr = 4 THEN PSET (x, y), 4  NEXTNEXTGET (1, 1)-(10, 10), scoutmaskCLSFOR y = 1 TO 15  FOR x = 1 TO 30    READ tilenumber    map(x, y) = tilenumber '''    IF tilenumber = 1 THEN PUT (x * 10, y * 10), grass, PSET    IF tilenumber = 2 THEN PUT (x * 10, y * 10), path, PSET    IF tilenumber = 3 THEN PUT (x * 10, y * 10), water, PSET    IF tilenumber = 4 THEN PUT (x * 10, y * 10), tent, PSET  NEXTNEXT'''Before PUTing the scout, GET the area where it will goGET (scoutx * 10, scouty * 10)-(scoutx * 10 + 10, scouty * 10 + 10), oldscoutareaPUT (scoutx * 10, scouty * 10), scoutmask, ANDPUT (scoutx * 10, scouty * 10), scout, OR'''********************************************************************DO  DO '''Changed GOTOs to DO/LOOPs, on Mentat's good advice    DO '''Changed GOTOs to DO/LOOPs, on Mentat's good advice      p$ = "": WHILE p$ = "": p$ = INKEY$: WEND '''      p$ = RIGHT$(p$, 1) '''    LOOP UNTIL p$ = "H" OR p$ = "K" OR p$ = "M" OR p$ = "P"   '''     oldscoutx = scoutx    oldscouty = scouty    IF p$ = "H" AND scouty > 1 THEN scouty = scouty - 1    IF p$ = "K" AND scoutx > 1 THEN scoutx = scoutx - 1    IF p$ = "M" AND scoutx < 30 THEN scoutx = scoutx + 1    IF p$ = "P" AND scouty < 15 THEN scouty = scouty + 1    '''Check for water area in next jump; if water, don't allow move    IF map(scoutx, scouty) = 3 THEN scoutx = oldscoutx: scouty = oldscouty  LOOP WHILE map(scoutx, scouty) = 3 '''   IF oldscoutx <> scoutx OR oldscouty <> scouty THEN    '''RESTORE tilenumber '''REMarked outGOTO skip1 ''''''Following code disabled by above GOTO    FOR y = 1 TO 15      FOR x = 1 TO 30        'READ tilenumber '''REMarked out by Ralph        tilenumber = map(x, y) '''new, by Ralph        IF tilenumber = 1 THEN PUT (x * 10, y * 10), grass, PSET        IF tilenumber = 2 THEN PUT (x * 10, y * 10), path, PSET        IF tilenumber = 3 THEN PUT (x * 10, y * 10), water, PSET        IF tilenumber = 4 THEN PUT (x * 10, y * 10), tent, PSET      NEXT    NEXTskip1:       '''Restore oldscout's location with proper background    PUT (oldscoutx * 10, oldscouty * 10), oldscoutarea, PSET '''    '''GET the new scout location area    GET (scoutx * 10, scouty * 10)-(scoutx * 10 + 10, scouty * 10 + 10), oldscoutarea '''       PUT (scoutx * 10, scouty * 10), scoutmask, AND    PUT (scoutx * 10, scouty * 10), scout, OR  END IFLOOP UNTIL p$ = CHR$(27)'''********************************************************************SYSTEMgrass:DATA 0,0,0,0,0,0,0,0,0,0DATA 0,0,1,0,0,0,0,0,0,0DATA 0,0,0,0,0,1,0,0,0,0DATA 0,0,0,0,0,0,0,0,0,0DATA 0,0,0,0,0,0,0,0,0,0DATA 0,0,0,0,0,0,1,0,0,0DATA 0,1,0,0,0,0,0,0,0,0DATA 0,0,0,0,0,0,0,0,0,0DATA 0,0,0,0,0,0,0,1,0,0DATA 0,0,0,0,0,0,0,0,0,0path:DATA 0,0,0,0,0,0,0,0,0,0DATA 0,0,0,0,0,0,0,0,0,0DATA 0,0,0,0,0,0,0,0,0,0DATA 0,0,0,0,0,0,0,0,0,0DATA 0,0,0,0,0,0,0,0,0,0DATA 0,0,0,0,0,0,0,0,0,0DATA 0,0,0,0,0,0,0,0,0,0DATA 0,0,0,0,0,0,0,0,0,0DATA 0,0,0,0,0,0,0,0,0,0DATA 0,0,0,0,0,0,0,0,0,0water:DATA 0,0,0,0,0,0,0,0,0,0DATA 1,1,1,1,0,0,0,0,0,0DATA 0,0,0,0,0,0,0,0,0,0DATA 0,0,0,0,0,1,1,1,1,0DATA 0,0,0,0,0,0,0,0,0,0DATA 1,1,1,1,0,0,0,0,0,0DATA 0,0,0,0,0,0,0,0,0,0DATA 0,0,0,0,0,1,1,1,1,0DATA 0,0,0,0,0,0,0,0,0,0DATA 1,1,1,1,0,0,0,0,0,0tent:DATA 0,0,0,0,0,0,0,0,0,0DATA 0,0,0,0,1,1,0,0,0,0DATA 0,0,0,1,1,1,1,0,0,0DATA 0,0,0,1,2,2,1,0,0,0DATA 0,0,1,1,2,2,1,1,0,0DATA 0,0,1,1,2,2,1,1,0,0DATA 0,1,1,1,2,2,1,1,1,0DATA 0,1,1,2,2,2,2,1,1,0DATA 1,1,1,2,2,2,2,1,1,1DATA 1,1,1,2,2,2,2,1,1,1scout:DATA 0,0,0,0,1,1,0,0,0,0DATA 0,0,0,1,1,1,1,1,0,0DATA 0,0,0,3,3,3,3,0,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,1,1,3,3,3,3DATA 1,1,1,1,2,2,1,1,1,1,1,4,1,1,1,1,1,1,1,1,1,4,1,1,1,1,3,3,3,3DATA 1,1,1,1,2,2,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,3,3,3,3DATA 2,2,2,2,2,2,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,3,3,3DATA 1,1,1,1,2,2,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,3,3DATA 1,1,1,1,2,2,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,3

Statistics: Posted by Ralph — Sun Jul 27, 2008 2:19 pm


]]>
2008-07-27T13:59:35-05:00 2008-07-27T13:59:35-05:00 http://petesqbsite.com/phpBB3/viewtopic.php?p=17544#p17544 <![CDATA[Need help - Strange tile problem]]> I accept your good explanation, namely, not to teach using GOTOs, to avoid the possibility of difficult-to-follow, spagetti code. It's a good reason for me to avoid it in public and, cetainly, in teaching. I use it, with care and for short jumps, because I learned programming (I consider myself an amateur programmer with a smidgen of understanding) with the GOTO and the WHILE/WEND. I think the DO/LOOP came out later, and, I never took it up. But, I see your point, and will try to change my habits in this respect.
Thank you for your kind and considerate explanations.

Statistics: Posted by Ralph — Sun Jul 27, 2008 1:59 pm


]]>
2008-07-27T12:39:43-05:00 2008-07-27T12:39:43-05:00 http://petesqbsite.com/phpBB3/viewtopic.php?p=17543#p17543 <![CDATA[Need help - Strange tile problem]]> ever teach programming with goto. If you were just sharing your own code about your own project with experienced members, then I wouldn't care.

Why do I care? Because newer coders write longer and longer programs as they develop. Goto makes it harder to write larger programs. See the problem? You make like Dr. Pepper just like I do, but don't water a tree with it.

Now I sound all grouchy. :?

9+9 is 12, in hex. :D

Statistics: Posted by Mentat — Sun Jul 27, 2008 12:39 pm


]]>
2008-07-27T12:23:27-05:00 2008-07-27T12:23:27-05:00 http://petesqbsite.com/phpBB3/viewtopic.php?p=17542#p17542 <![CDATA[Need help - Strange tile problem]]>
THERE IS NOTHING WRONG with a proper use of GOTO. Of course, we can always use a DO/LOOP instead of a GOTO. And, the angry rage against the use of the GOTO goes on and on. Why can't everybody simply accept a PROPERLY used GOTO?

Oh, and, 9 + 9 = 12 is wrong! 9 + 9 = 18! And, when I turn it upside down, I get 6 + 6 = 21, which is also wrong! Yes, yes, I thought your signature is humorous, I'm just pulling your leg, ha, ha. No criticism intended! :)

Statistics: Posted by Ralph — Sun Jul 27, 2008 12:23 pm


]]>
2008-07-27T09:10:44-05:00 2008-07-27T09:10:44-05:00 http://petesqbsite.com/phpBB3/viewtopic.php?p=17541#p17541 <![CDATA[Need help - Strange tile problem]]> . Don't use GOTO. Why did they still keep that spaghetti machine from hell? Use proper loops.

Statistics: Posted by Mentat — Sun Jul 27, 2008 9:10 am


]]>
2008-07-26T22:03:09-05:00 2008-07-26T22:03:09-05:00 http://petesqbsite.com/phpBB3/viewtopic.php?p=17538#p17538 <![CDATA[Need help - Strange tile problem]]> This code DOES work! I've also added the "don't allow scout to get in the water". Please STUDY what I've done, and ask questions. Otherwise, this will be my last post on this thread.

Code:

'''Changes or additions by Ralph are identified with three apostrophes '''DIM grass(10, 10), path(10, 10), water(10, 10), tent(10, 10), scout(10, 10), scoutmask(10, 10)DIM oldscoutarea(10, 10), map(30, 15)'''SCREEN 13scoutx = 5scouty = 1FOR y = 1 TO 10FOR x = 1 TO 10READ clrIF clr = 1 THEN PSET (x, y), 10IF clr = 0 THEN PSET (x, y), 2NEXTNEXTGET (1, 1)-(10, 10), grassFOR y = 1 TO 10FOR x = 1 TO 10READ clrIF clr = 0 THEN PSET (x, y), 6IF clr = 1 THEN PSET (x, y), 14NEXTNEXTGET (1, 1)-(10, 10), pathFOR y = 1 TO 10FOR x = 1 TO 10READ clrIF clr = 0 THEN PSET (x, y), 3IF clr = 1 THEN PSET (x, y), 11NEXTNEXTGET (1, 1)-(10, 10), waterFOR y = 1 TO 10FOR x = 1 TO 10READ clrIF clr = 0 THEN PSET (x, y), 6IF clr = 1 THEN PSET (x, y), 8IF clr = 2 THEN PSET (x, y), 0NEXTNEXTGET (1, 1)-(10, 10), tentFOR y = 1 TO 10FOR x = 1 TO 10READ clrIF clr = 0 THEN PSET (x, y), 0IF clr = 1 THEN PSET (x, y), 5 '''was 2IF clr = 2 THEN PSET (x, y), 8IF clr = 3 THEN PSET (x, y), 14IF clr = 4 THEN PSET (x, y), 4NEXTNEXTGET (1, 1)-(10, 10), scoutFOR y = 1 TO 10  FOR x = 1 TO 10    READ clr    IF clr = 0 THEN PSET (x, y), 255    IF clr = 1 THEN PSET (x, y), 2    IF clr = 2 THEN PSET (x, y), 8    IF clr = 3 THEN PSET (x, y), 14    IF clr = 4 THEN PSET (x, y), 4  NEXTNEXTGET (1, 1)-(10, 10), scoutmaskCLSFOR y = 1 TO 15  FOR x = 1 TO 30    READ tilenumber    map(x, y) = tilenumber '''    IF tilenumber = 1 THEN PUT (x * 10, y * 10), grass, PSET    IF tilenumber = 2 THEN PUT (x * 10, y * 10), path, PSET    IF tilenumber = 3 THEN PUT (x * 10, y * 10), water, PSET    IF tilenumber = 4 THEN PUT (x * 10, y * 10), tent, PSET  NEXTNEXT'''Before PUTing the scout, GET the area where it will goGET (scoutx * 10, scouty * 10)-(scoutx * 10 + 10, scouty * 10 + 10), oldscoutareaPUT (scoutx * 10, scouty * 10), scoutmask, ANDPUT (scoutx * 10, scouty * 10), scout, OR'''********************************************************************DOagain1: '''  p$ = "": WHILE p$ = "": p$ = INKEY$: WEND '''  p$ = RIGHT$(p$, 1) '''   '''Check that an arrow key was pressed; if not, go to label again1:  IF p$ <> "H" AND p$ <> "K" AND p$ <> "M" AND p$ <> "P" THEN GOTO again1 '''   oldscoutx = scoutx  oldscouty = scouty  IF p$ = "H" AND scouty > 1 THEN scouty = scouty - 1  IF p$ = "K" AND scoutx > 1 THEN scoutx = scoutx - 1  IF p$ = "M" AND scoutx < 30 THEN scoutx = scoutx + 1  IF p$ = "P" AND scouty < 15 THEN scouty = scouty + 1  '''Check for water area in next jump; if water, don't allow jump  IF map(scoutx, scouty) = 3 THEN    scoutx = oldscoutx    scouty = oldscouty    GOTO again1  END IF  IF oldscoutx <> scoutx OR oldscouty <> scouty THEN    '''RESTORE tilenumber '''REMarked outGOTO skip1 ''''''Following code disabled by above GOTO    FOR y = 1 TO 15      FOR x = 1 TO 30        'READ tilenumber '''REMarked out by Ralph        tilenumber = map(x, y) '''new, by Ralph        IF tilenumber = 1 THEN PUT (x * 10, y * 10), grass, PSET        IF tilenumber = 2 THEN PUT (x * 10, y * 10), path, PSET        IF tilenumber = 3 THEN PUT (x * 10, y * 10), water, PSET        IF tilenumber = 4 THEN PUT (x * 10, y * 10), tent, PSET      NEXT    NEXTskip1:        '''Restore oldscout's location with proper background    PUT (oldscoutx * 10, oldscouty * 10), oldscoutarea, PSET '''    '''GET the new scout location area    GET (scoutx * 10, scouty * 10)-(scoutx * 10 + 10, scouty * 10 + 10), oldscoutarea '''       PUT (scoutx * 10, scouty * 10), scoutmask, AND    PUT (scoutx * 10, scouty * 10), scout, OR  END IFLOOP UNTIL p$ = CHR$(27)'''********************************************************************SYSTEMgrass:DATA 0,0,0,0,0,0,0,0,0,0DATA 0,0,1,0,0,0,0,0,0,0DATA 0,0,0,0,0,1,0,0,0,0DATA 0,0,0,0,0,0,0,0,0,0DATA 0,0,0,0,0,0,0,0,0,0DATA 0,0,0,0,0,0,1,0,0,0DATA 0,1,0,0,0,0,0,0,0,0DATA 0,0,0,0,0,0,0,0,0,0DATA 0,0,0,0,0,0,0,1,0,0DATA 0,0,0,0,0,0,0,0,0,0path:DATA 0,0,0,0,0,0,0,0,0,0DATA 0,0,0,0,0,0,0,0,0,0DATA 0,0,0,0,0,0,0,0,0,0DATA 0,0,0,0,0,0,0,0,0,0DATA 0,0,0,0,0,0,0,0,0,0DATA 0,0,0,0,0,0,0,0,0,0DATA 0,0,0,0,0,0,0,0,0,0DATA 0,0,0,0,0,0,0,0,0,0DATA 0,0,0,0,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1,1,1,1,1,1,3DATA 1,1,1,1,2,2,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,3,3DATA 1,1,1,1,2,2,2,2,2,2,2,2,2,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,3,3DATA 1,1,1,1,2,2,1,1,1,1,1,1,2,1,1,1,1,1,1,1,1,1,1,1,1,1,1,3,3,3DATA 1,1,1,1,2,2,1,1,1,1,1,1,2,2,2,2,2,1,1,1,1,1,1,1,1,1,1,3,3,3DATA 1,1,1,1,2,2,1,1,1,1,1,1,1,1,1,1,2,4,1,1,1,1,1,1,1,1,3,3,3,3DATA 1,1,1,1,2,2,1,1,1,1,1,1,1,1,1,1,2,1,1,1,1,1,1,1,1,1,3,3,3,3DATA 1,1,1,1,2,2,1,1,1,4,1,1,1,1,1,1,2,1,1,1,1,1,1,1,1,1,3,3,3,3DATA 1,1,1,1,2,2,1,1,1,2,1,1,1,1,1,1,2,2,2,2,2,2,1,1,1,1,3,3,3,3DATA 1,1,1,1,2,2,2,2,2,2,2,2,1,1,1,1,1,1,1,1,1,2,1,1,1,1,3,3,3,3DATA 1,1,1,1,2,2,1,1,1,1,1,4,1,1,1,1,1,1,1,1,1,4,1,1,1,1,3,3,3,3DATA 1,1,1,1,2,2,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,3,3,3,3DATA 2,2,2,2,2,2,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,3,3,3DATA 1,1,1,1,2,2,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,3,3DATA 1,1,1,1,2,2,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,3

Statistics: Posted by Ralph — Sat Jul 26, 2008 10:03 pm


]]>
2008-07-26T18:18:01-05:00 2008-07-26T18:18:01-05:00 http://petesqbsite.com/phpBB3/viewtopic.php?p=17537#p17537 <![CDATA[Need help - Strange tile problem]]>
Here's I would do the whole thing if it were my project. Except that I would draw my tiles and sprite in Paint, then BLOAD them. This code runs fast enough so you can redraw every frame, without flicker. It takes care of collision detection with water and the sides of the map.

Code:

screenres 640, 480, 8'graphics imagesdim grass as integer ptr = imageCreate(10, 10)dim path  as integer ptr = imageCreate(10, 10)dim water as integer ptr = imageCreate(10, 10)dim tent  as integer ptr = imageCreate(10, 10)dim scout as integer ptr = imageCreate(10, 10)dim map(15, 30) as integer'initialize variablesdim scoutX as integer = 5dim scouty as integer = 1dim clr    as integerdim x      as integerdim y      as integerdim key    as stringdim vy     as integerdim vx     as integer'load grass tileFOR y = 1 TO 10    FOR x = 1 TO 10        READ clr        pset (x, y), clr    NEXTNEXTGET (1, 1)-(10, 10), grass'load path tileFOR y = 1 TO 10    FOR x = 1 TO 10        READ clr        pset (x, y), clr    NEXT xNEXT yGET (1, 1)-(10, 10), path'load water tileFOR y = 1 TO 10    FOR x = 1 TO 10        READ clr        pset (x, y), clr    NEXT xNEXT yGET (1, 1)-(10, 10), water'load tent tileFOR y = 1 TO 10    FOR x = 1 TO 10        READ clr        pset (x, y), clr    NEXT xNEXT yGET (1, 1)-(10, 10), tent'spriteFOR y = 1 TO 10    FOR x = 1 TO 10        READ clr        pset (x, y), clr    NEXT xNEXT yGET (1, 1)-(10, 10), scout'load mapFOR y = 1 TO 15    FOR x = 1 TO 30        read clr        map(y, x) = clr    NEXT xNEXT y    DO    'Prevent flicker    screenunlock    screenlock    cls        'keyboard input    key = INKEY$        vy = 0    vx = 0        'move    IF key = chr(255) + chr(72) THEN vy = -1    IF key = chr(255) + chr(80) THEN vy = 1    IF key = chr(255) + chr(75) THEN vx = -1    IF key = chr(255) + chr(77) THEN vx = 1    'Check against borders and water    if scoutX + vx > 0 and scoutX + vx <31> 0 and scoutY + vy < 16 then            if map(scouty + vy, scoutx + vx) <> 3 then                scoutX += vx                scouty += vy            end if        end if    end if    'draw map    FOR y = 1 TO 15        FOR x = 1 TO 30            IF map(y, x) = 1 THEN PUT (x * 10, y * 10), grass, PSET            IF map(y, x) = 2 THEN PUT (x * 10, y * 10), path, PSET            IF map(y, x) = 3 THEN PUT (x * 10, y * 10), water, PSET            IF map(y, x) = 4 THEN PUT (x * 10, y * 10), tent, PSET        NEXT x    NEXT y        'Draw the little dude    PUT (scoutX * 10, scoutY * 10), scout, transLOOP UNTIL multikey(1)'release imagesimageDestroy(grass)imageDestroy(path)imageDestroy(water)imageDestroy(tent)imageDestroy(scout)end'grassDATA 2, 2, 2, 2, 2, 2, 2, 2, 2, 2DATA 2, 2,10, 2, 2, 2, 2, 2, 2, 2DATA 2, 2, 2, 2, 2,10, 2, 2, 2, 2DATA 2, 2, 2, 2, 2, 2, 2, 2, 2, 2DATA 2, 2, 2, 2, 2, 2, 2, 2, 2, 2DATA 2, 2, 2, 2, 2, 2,10, 2, 2, 2DATA 2,10, 2, 2, 2, 2, 2, 2, 2, 2DATA 2, 2, 2, 2, 2, 2, 2, 2, 2, 2DATA 2, 2, 2, 2, 2, 2, 2,10, 2, 2DATA 2, 2, 2, 2, 2, 2, 2, 2, 2, 2'pathDATA 6,6,6,6,6,6,6,6,6,6DATA 6,6,6,6,6,6,6,6,6,6DATA 6,6,6,6,6,6,6,6,6,6DATA 6,6,6,6,6,6,6,6,6,6DATA 6,6,6,6,6,6,6,6,6,6DATA 6,6,6,6,6,6,6,6,6,6DATA 6,6,6,6,6,6,6,6,6,6DATA 6,6,6,6,6,6,6,6,6,6DATA 6,6,6,6,6,6,6,6,6,6DATA 6,6,6,6,6,6,6,6,6,6'waterDATA  3, 3, 3, 3, 3, 3, 3, 3, 3, 3DATA 11,11,11,11, 3, 3, 3, 3, 3, 3DATA  3, 3, 3, 3, 3, 3, 3, 3, 3, 3DATA  3, 3, 3, 3, 3,11,11,11,11, 3DATA  3, 3, 3, 3, 3, 3, 3, 3, 3, 3DATA 11,11,11,11, 3, 3, 3, 3, 3, 3DATA  3, 3, 3, 3, 3, 3, 3, 3, 3, 3DATA  3, 3, 3, 3, 3,11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