Omnimaga
Calculator Community => TI Calculators => Axe => Topic started by: Munchor on January 13, 2011, 11:02:52 am
-
I've been trying to make a scrolling engine but I'm not having much luck :S
(http://img.removedfromgame.com/imgs/0-ScrollingProblem.gif)
.SCROLL
ClrDraw
[003C7E7E7E7E3C00]->Pic1
[FF818181818181FF]->Pic2
Pt-On(40,40,Pic2
Repeat getKey(15)
Pt-On(X,Y,Pic1
If getKey(1)
Y+1->Y
Vertical -
End
If getKey(2)
X-1->X
Horizontal +
End
If getKey(3)
X+1->X
Horizontal -
End
If getKey(4)
Y-1->Y
Vertical +
End
DispGraph
End
That is my code and what is happening, attached is the source code.
My problem is that the scrolling is not working like, for example, in a RPG, and I want it for each time the ball moves 1 pxl, that little square moves one pxl too in a controlled way, isntead of what is happening (everything is crazy)
-
First you need make a tilemap. Next you can do a scrolling engine to display a tilemap in function of your sprite position.
-
I've been trying to make a scrolling engine but I'm not having much luck :S
(http://img.removedfromgame.com/imgs/0-ScrollingProblem.gif)
.SCROLL
ClrDraw
[003C7E7E7E7E3C00]->Pic1
[FF818181818181FF]->Pic2
Pt-On(40,40,Pic2
Repeat getKey(15)
Pt-On(X,Y,Pic1
If getKey(1)
Y+1->Y
Vertical -
End
If getKey(2)
X-1->X
Horizontal +
End
If getKey(3)
X+1->X
Horizontal -
End
If getKey(4)
Y-1->Y
Vertical +
End
DispGraph
End
That is my code and what is happening, attached is the source code.
My problem is that the scrolling is not working like, for example, in a RPG, and I want it for each time the ball moves 1 pxl, that little square moves one pxl too in a controlled way, isntead of what is happening (everything is crazy)
I think the problem is that each time you use vertical or horizontal, you also increment the position of the black ball, effectively doubling the distance that you move? Try using either horizontal/vertical, or incrementing X and Y. Using both might cause problems.
Assuming you want to continue using horizontal and vertical, and assuming you don't want the black trail, try this:
-
Michael, your code isn't showing up...
-
Michael, your code isn't showing up...
Yeah it isn't :S
-
Michael, your code isn't showing up...
Yeah it isn't :S
Bizarre. Here it is:
.SCROLL
[003C7E7E7E7E3C00]->Pic1
[FF818181818181FF]->Pic2
10->X->Y
Repeat getKey(15)
ClrDraw
Pt-On(35,35,Pic1)
Pt-On(X,Y,Pic2)
DispGraph
If getKey(1)
Y-1->Y
End
If getKey(2)
X+1->X
End
If getKey(3)
X-1->X
End
If getKey(4)
Y+1->Y
End
End
Disclaimer: This hasn't been tested, so you might have to fiddle with it slightly to get it to work the way you want.
I assumed that you wanted the black ball to move, and not leave behind a trail.
-
Thanks much!
-
Here a scroll engine with tilemapping : (http://img225.imageshack.us/img225/7618/tp2.gif)
Code :
:.RPG
:
:0→A→B
:.Position of tilemap
:
:4→V+1→U
:.V and U are position of cross
:
:Repeat getKey(15)
:If getKey(3) and (sub(ZIP,A+U+1,B+V)=0
: If A<24 and (U=5)
: +A→A
: ElseIf U<11
: +U→U
: End
:ElseIf getKey(2) and (sub(ZIP,A+U-1,B+V)=0
: If (U=5) and (A>0)
: A-1→A
: ElseIf U>0
: U-1→U
: End
:End
:If getKey(1) and (sub(ZIP,A+U,B+V+1)=0
: If B<8 and (V=4)
: +B→B
: ElseIf V<7
: +V→V
: End
:ElseIf getKey(4) and (sub(ZIP,A+U,B+V-1)=0
: If B>0 and (V=4)
: B-1→B
: ElseIf V>0
: V-1→V
: End
:End
:DispGraphClrDraw
:sub(TLM)
:Pt-On(U*8,V*8,[181818FFFF181818]
:End
:Return
:
:.Subroutine to wait no key pressed
:Lbl NOG
:While getKey(0)
: Pause 5
:End
:Return
:
:.Tile
:[0000000000000000]→Pic1
:.Tile n°0
:[FFFFFFFFFFFFFFFF]
:.Tile n°1
:[55AA55AA55AA55AA]
:.Tile n°2
:[7FBFDFEFF7FBFDFE]
:.Tile n°3
:
:.You can up to 16 tiles
:
:.Map
:[111111111111111111111111111111111111]→GDB1
:.Line 1
:[100000000000000000000000000000000001]
:.Line 2
:[100000000000000000333333000000000001]
:.Line 3
:[100000000000000000333333000000000001]
:.Line 4
:[100000000000000000333333000000000001]
:.Line 5
:[100000000000000000330033000000000001]
:.Line 6
:[100000000000000000330033000000000001]
:.Line 7
:[100000000000000000333033000000000001]
:.Line 8
:[100000000000000000330033000000000001]
:.Line 9
:[100000000000000000330333000000000001]
:.Line 10
:[100000000000000000330333000000000001]
:.Line 11
:[100000000000000000000000000000000001]
:.Line 12
:[100000000000000000000000000000002221]
:.Line 13
:[100000000000000000000000000000002221]
:.Line 14
:[100000000000000000000000000000002221]
:.Line 15
:[111111111111111111111111111111111111]
:.Line 16
:
:.Subroutine to display each tile on screen
:Lbl TLM
:For(Y,0,7)
: For(X,0,11)
: sub(ZIP,X+A,Y+B)→r1
: Pt-On(X*8,Y*8,r1*8+Pic1
: End
:End
:Return
:
:.Subroutine to extract byte from map (GDB1)
:Lbl ZIP
:r2*36+r1→r1
:{r1/2+GDB1}→r2
:If r1^2
: r2^16
:Else
: r2/16
:End
1200 byte source, 1300 byte.