0 Members and 1 Guest are viewing this topic.
Hey,So, I'm wanting to program a game where I draw a tilemap for the background and have masked sprites for the character and objects/enemies, etc. It'd be a side-scrolling gameI read here that the quickest way to get a tilemap to shift is by using the Horizontal or Vertical commands. You then redraw the side the direction the map shifted. Like, if the map moves down, you redraw that side, etc. This avoids drawing the whole map over again.
If the screen has masked sprites on it, will they shift along with everything else when I use the Horizontal/Vertical commands? How could I avoid it?
It probably has to do with the front and back buffers, but I dont know too much about them, so an explanation on buffers could be helpful!
//Shifts Map background 1 pixelLbl Shift//Tell which Tile is on the top left of the screen!If {GDB0}/2/2/2/2→A=0:15-A→A:End!If {1+GDB0}/2/2/2/2→B=0:15-B→B:EndIf r₁=1Vertical-ʳ16*B→CFor(J,A,A+7)C+J+64→NDraw(16*J+{GDB0},C+64+{1+GDB0},{N+GDB0MAP}*32+Pic0TileEndElseIf r₁=2Horizontal+ʳFor(I,B,B+5)16*I+A→NDraw(16*A+{GDB0},16*I+{1+GDB0},{N+GDB0MAP}*32+Pic0Tile EndElseIf r₁=3Horizontal-ʳ For(I,B,B+5)16*I+A+6→NDraw(16*A+96+{GDB0},16*I+{1+GDB0},{N+GDB0MAP}*32+Pic0Tile EndElseIf r₁=4Vertical+ʳ16*B→CFor(J,A,A+7)C+J→NDraw(16*J+{GDB0},C+{1+GDB0},{N+GDB0MAP}*32+Pic0TileEndEndCopy(L₃) Return--------------------------Here's the action key that calls shift. The map cannot scroll past the boundaries.Lbl ActionKey{GDB0}→X{1+GDB0}→YIf getKey(1)If Y≠64{1+GDB0}--Shift(1)EndEndIf getKey(2)If X≠0{GDB0}++Shift(2)EndEndIf getKey(3)If X≠96{GDB0}--Shift(3)EndEndIf getKey(4)If Y≠0{1+GDB0}++Shift(4)EndEndReturn
!If {GDB0}/2/2/2/2→A=0:15-A→A:End!If {1+GDB0}/2/2/2/2→B=0:15-B→B:End
Lbl Draw Pt-Off(r₁,r₂,r₃)ʳ Pt-Off(r₁+8,r₂,r₃+8)ʳ Pt-Off(r₁+8,r₂+8,r₃+16)ʳ Pt-Off(r₁,r₂+8,r₃+24)ʳReturn
Lbl MainRepeat getKey(15)//ClrDrawActionKey()//redraw the map by pressing enterIf getKey(9)DrawMap({GDB0},{1+GDB0})EndDispGraphEndReturn
[...]As a side note, i'm using wabbitemu to emulate, and i'm not sure how to record video on it...