61
Axe / Re: Correct way to do smooth scrolling in a tilemapper?
« on: December 19, 2012, 06:43:52 pm »
Sorry for double-post
But i concider this an "update"
This is my way of doing it, it's kinda the same but not as optimised as squidget's code, and it's probably slower with some bugs cause it's out of my head
And this doesn't include collision detection yet, but it's easy to implement...
Edit1: forgot to paste code
But i concider this an "update"
This is my way of doing it, it's kinda the same but not as optimised as squidget's code, and it's probably slower with some bugs cause it's out of my head
Code: [Select]
.smtscrll
.tiles (black and white)
[0000000000000000]-> pic0
[FFFFFFFFFFFFFFFF]
.sprite 8*8 stored in pic1
.map (15*10)
[010101010101010101010101010101]->GDB0
[010000000000000000000000000001] .this one 8 times
[010101010101010101010101010101]
.initialize vars (x=x-pos , y=y-pos , c=horizontal scroll, d= vertical scroll)
0->C->D+8->X->Y
.till [clear] is pressed
Repeat Getkey(15)
MOVE()
MAP()
.2 subroutines are called
Pt-on(X,Y,pic1)
DispGraph
End
Lbl MOVE
X+(Getkey(3) and (X<88))-(Getkey(2) and (X>0))->X
C+(Getkey(3) and (X=88))-(Getkey(2) and (X=0))->C
.only change X when it's on screen If it's on border of screen the change the scroll var (same for Y)
Y+(Getkey(1) and (Y<56))-(Getkey(4) and (Y>0))->Y
D+(Getkey(1) and (Y=56))-(Getkey(4) and (Y=0))->D
Return
Lbl MAP
For(A,C/8,C/8+12)
For(B,D/8,D/8+8)
Pt-on(A*8-C,B*8-C,{15*B+A+GDB0}*8+pic0)
.so this says: draw the map, where 15=the length of the map
End
End
Return
.end of program, no collision detection yet but easy to implement... Question? Ask me...
And this doesn't include collision detection yet, but it's easy to implement...
Edit1: forgot to paste code