So I have this current problem while playing with tilemaps.

Code:

:ClrDraw
:8→X
:8→Y
:[[0,0,0,0,0,0,0,0,0,0,0,0][0,1,1,1,1,1,1,1,1,1,1,0][0,1,1,1,1,1,1,1,1,1,1,0][0,1,1,1,1,1,1,1,1,1,1,0][0,1,1,1,1,1,1,1,1,1,1,0][0,1,1,1,1,1,1,1,1,1,1,0][0,1,1,1,1,1,1,1,1,1,1,0][0,0,0,0,0,0,0,0,0,0,0,0]]→[A]
:
:0→K
:Repeat K=45

:¦ real(2,0,0,0,12,8,0,12,0,8,1,0,8,0
:¦ real(1,X,Y,1,8,1,2,0,0,0,1

:¦ X→S:Y→T

:¦ getKey→K
:¦ If K=24
:¦ X-8→X
:¦ If K=25
:¦ Y-8→Y
:¦ If K=26
:¦ X+8→X
:¦ If K=34
:¦ Y+8→Y

:¦ If [A](X,Y)=0:Then
:¦ ¦ S→X:T→Y
:¦ End
:
:End


And it seems to redirect me to the beginning line of code:

Code:

:8→X
:8→Y
://Beginning of Matrix : It directs me here.


I'm not sure what it is that's wrong with my code, and i've tried changing:

Code:

:¦ If [A](X,Y)=0:Then
:¦ ¦ S→X:T→Y
:¦ End


To:


Code:

:¦ If [A](X/8,Y/8)=0:Then
:¦ ¦ S→X:T→Y
:¦ End


But that seems to prevent me from going to most of the places on the tile-map.
So how would I get this to work..?

EDIT: Sorry, this is using xLIB. (Forgot to mention.)
I believe this was rectified already, you may want to explain the fix for everyone? Smile.
Remember that in TI-BASIC, for anything that doesn't use graph coordinates, the X and Y are inverted. So it would be [A](Y,X) instead of [A](X,Y) Wink
Yes, the solution was just to flip the X and Y coords, because BASIC is silly Razz
(Along with re-storing the previous coords of where the character use to be. Since for some reason I removed that from my code o.O, but it's back and working.)
I tested it out, you also need to insert this


Code:
If [A] (y/8+1, x/8+1)


because the top left of the matrix is 1,1 and the top left of the display is 0,0
Yes, another add-on I forgot to mention.
Again, thanks for the help ^_^
If this program gets bigger, and you are crunching for size, you can change:


Code:
If K=24
X-8→X
If K=25
Y-8→Y
If K=26
X+8→X
If K=34
Y+8→Y


With:

Code:
X+8(K=26)-8(K=24)→X
Y+8(K=34)-8(K=25)→Y


Other than that, It looks like fun. Had to look up the real(2 command. Might use it myself in a program.

Good luck.

Code:
X-8((K=24)-(K=26)->X
Y-8((K=25)-(K=34->Y


Saves a byte, also very not recommended to use X and Y for graph screen coordinates unless the library/setup you are using requires it.
ninjas: here's what I have so far


Code:
SetUpEditor MAT
:1→∟MAT(1
:1→θ
:ClrDraw
:8→X
:8→Y
:Lbl RC
:DelVar P
:If ∟MAT(1)=1
:[[0,0,0,0,0,0,0,0,0,0,0,0][0,1,1,1,1,1,1,1,1,1,1,0][0,1,1,1,1,1,1,1,1,1,1,0][0,1,1,1,1,1,1,1,1,1,1,0][0,1,1,1,1,1,1,1,1,1,1,3][0,1,1,1,1,1,1,1,1,1,1,0][0,1,1,1,1,1,1,1,1,1,1,0][0,0,0,0,0,0,0,0,0,0,0,0→[A]
:If ∟MAT(1)=2
:[[0,0,0,0,0,0,0,0,0,0,0,0][0,1,1,1,1,1,1,1,1,1,1,0][0,1,1,1,1,1,1,1,1,1,1,0][0,1,1,1,1,1,1,1,1,1,1,0][3,1,1,1,1,1,1,1,1,1,1,0][0,1,1,1,1,1,1,1,1,1,1,0][0,1,1,1,1,1,1,1,1,1,1,0][0,0,0,0,0,0,0,0,0,0,0,0→[A]
:If θ>∟MAT(1)
:Then
:80→X
:32→Y
:End
:If θ<∟MAT(1)
:Then
:8→X
:32→Y
:End
:0→K
:Lbl ST
:real(2,0,0,0,12,8,0,12,0,8,1,0,8,0
:
:real(1,X,Y,1,8,1,2,0,0,0,1
:
:X→S:Y→T
:
:Repeat K
:getKey→K
:End
:
:X-8(K=24)+8(K=26)→X
:Y-8(K=25)+8(K=34)→Y
:If [A](Y/8+1,X/8+1)=0:Then
:S→X:T→Y
:End
:
:If ((X=88)(Y=32)) or ((X=0)(Y=32)):Then
:∟MAT(1)→θ
:∟MAT(1)+((X=88)(Y=32))-((X=0)(Y=32))→∟MAT(1
:1→P
:8→A:8→B
:End
:If P=1
:Goto RC
:
:If K=45
:Stop
:
:
:Goto ST



Go make somthing of it.
In this,


Code:
If θ>∟MAT(1)
:Then
:80→X
:32→Y
:End
:If θ<∟MAT(1)
:Then
:8→X
:32→Y
:End


Add this

Code:
If θ>∟MAT(1)
:Then
:80→X
:32→Y
:For(A,1,94
:real(4,3,1,1
:End
:End
:If θ<∟MAT(1)
:Then
:8→X
:32→Y
:For(A,1,94
:real(4,2,1,1
:End
:End
  
Register to Join the Conversation
Have your own thoughts to add to this or any other topic? Want to ask a question, offer a suggestion, share your own programs and projects, upload a file to the file archives, get help with calculator and computer programming, or simply chat with like-minded coders and tech and calculator enthusiasts via the site-wide AJAX SAX widget? Registration for a free Cemetech account only takes a minute.

» Go to Registration page
Page 1 of 1
» All times are UTC - 5 Hours
 
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum

 

Advertisement