0 Members and 3 Guests are viewing this topic.
.TITLE[SPRITES][HEX MAP]5->X3->YRepeat getKey(15)sub(MOVE)sub(SCREEN)EndLbl MOVEIf getKey(4):Y--ElseIf getKey(3):X++ElseIf getKey(1):Y++ElseIf getKey(2):X--:EndReturnLbl SCREENClrDrawClrDraw^^rFor(B,0,7)For(A,0,11)Pt-On(A*8,B*8,{32*(B+Y)+A+X+GDB0}*8+Pic0)Pt-On(A*8,B*8,{32*(B+Y)+A+X+GDB0}*8+Pic1)^^rEndEndText(0,0,(32*(B+Q)+A+P+GDB0))Pt-Off(40,24,Pic2+8)Pt-Off(40,24,Pic2)^^rDispGraphDispGraph^^rReturn
Pt-On(A*8,B*8,((B+Y→D<32?A+X→C<32)?{D*32+C+GDB0}*8,BLACK_TILE_INDEX)+Pic0→C)Pt-On(A*8,B*8,C-Pic0+Pic1)ʳ
Is your tilemap a set area in memory? Like do you actually have tile data stored somewhere in memory?
Do you always know the tilemaps size?
There are two solutions to this problem:Add enough black tiles around the edges of your tilemap so that the camera can never move far enough to go past them. This only costs as much extra time as it takes to perform the larger Y-coordinate multiplication to look up a tile, but does cost a fair amount of extra map space, so might not be ideal.Check if a tile to render's coordinates are outside of the map, and if so, produce a black tile instead. This only costs a small amount of time and requires no extra map data, so is probably the desired solution. Your map tile drawing code should then look something like the following (untested!), which should look up the tile index normally if both coordinates are between 0 and 31 or return the black tile index if not:Code: [Select]Pt-On(A*8,B*8,((B+Y→D<32?A+X→C<32)?{D*32+C+GDB0}*8,BLACK_TILE_INDEX)+Pic0→C)Pt-On(A*8,B*8,C-Pic0+Pic1)ʳUnrelated to your question, but there's also a good potential for optimization (and a bit of a bug) with how you display each frame and prepare the next. The optimization is that DispGraphʳ : ClrDraw : ClrDrawʳ can all be done in one command with DispGraphClrDrawʳ. And the bug is that the DispGraph without the ʳ shouldn't be there, as you have two display commands fighting between monochrome and grayscale graphics.
Pt-On(A*8,B*8,((B+Y→D<32?A+X→C<32)?{D*32+C+GDB0},BLACK_TILE_INDEX)*8→C+Pic0)Pt-On(A*8,B*8,C+Pic1)ʳ