Author Topic: xLIB-BASIC ERR:DIM  (Read 4060 times)

0 Members and 1 Guest are viewing this topic.

Offline hellninjas

  • LV7 Elite (Next: 700)
  • *******
  • Posts: 625
  • Rating: +17/-0
    • View Profile
xLIB-BASIC ERR:DIM
« on: September 15, 2013, 05:20:17 pm »
So I have this current problem while playing with tilemaps.
Code: [Select]
: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: [Select]
: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: [Select]
:¦ If [A](X,Y)=0:Then
:¦ ¦ S→X:T→Y
:¦ End

To:

Code: [Select]
:¦ 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.)

Offline DJ Omnimaga

  • Clacualters are teh gr33t
  • CoT Emeritus
  • LV15 Omnimagician (Next: --)
  • *
  • Posts: 55943
  • Rating: +3154/-232
  • CodeWalrus founder & retired Omnimaga founder
    • View Profile
    • Dream of Omnimaga Music
Re: xLIB-BASIC ERR:DIM
« Reply #1 on: September 15, 2013, 05:24:12 pm »
Wait, do you mean it keeps looping back to the beginning of the code? That seems strange, considering there's no While/For/If/Repeat/etc before the 1st code you posted.

Offline hellninjas

  • LV7 Elite (Next: 700)
  • *******
  • Posts: 625
  • Rating: +17/-0
    • View Profile
Re: xLIB-BASIC ERR:DIM
« Reply #2 on: September 15, 2013, 05:26:45 pm »
Sorry, I should've been more clear.

When I start the program, if I move my character left, or up, it gives me the error: "ERR:DIM"
Which, if I press "Goto Error" it brings me to that said line of code.

Code: [Select]
:8→X
:8→Y
://Beginning of Matrix : It directs me here.
« Last Edit: September 15, 2013, 05:26:58 pm by hellninjas »

Offline tr1p1ea

  • LV7 Elite (Next: 700)
  • *******
  • Posts: 647
  • Rating: +110/-0
    • View Profile
Re: xLIB-BASIC ERR:DIM
« Reply #3 on: September 15, 2013, 05:50:12 pm »
Remember that matrices on the 83+ are column first, so it should be [A](Y,X).
"My world is Black & White. But if I blink fast enough, I see it in Grayscale."


Offline DJ Omnimaga

  • Clacualters are teh gr33t
  • CoT Emeritus
  • LV15 Omnimagician (Next: --)
  • *
  • Posts: 55943
  • Rating: +3154/-232
  • CodeWalrus founder & retired Omnimaga founder
    • View Profile
    • Dream of Omnimaga Music
Re: xLIB-BASIC ERR:DIM
« Reply #4 on: September 15, 2013, 05:50:41 pm »
Oh I found it! It took a while because I got used to HP BASIC >.<. With some TI-BASIC commands, X and Y are inverted, so instead of If [A](X,Y)=0 you have to use If [A](Y,X)=0. Even then, try to avoid using Y at any cost, because some TI-OS bug will often reset it to zero.

EDIT Ninja'd. I think that every pixel-based command are inverted, but not graph-based ones.
« Last Edit: September 15, 2013, 05:51:23 pm by DJ Omnimaga »

Offline hellninjas

  • LV7 Elite (Next: 700)
  • *******
  • Posts: 625
  • Rating: +17/-0
    • View Profile
Re: xLIB-BASIC ERR:DIM
« Reply #5 on: September 15, 2013, 08:19:15 pm »
So because the values of X and Y reach 0, that's what I end up checking for in the Matrix, which doesn't have a 0,0.
But if I add one to X or Y than my sprite has the ability to go off the field.
This is getting frustrating :P

Offline tr1p1ea

  • LV7 Elite (Next: 700)
  • *******
  • Posts: 647
  • Rating: +110/-0
    • View Profile
Re: xLIB-BASIC ERR:DIM
« Reply #6 on: September 15, 2013, 08:48:37 pm »
Just out of interest, where are you adding 1?

You only need to do it in the matrix check: If [A]((Y/8)+1,(X/8)+1)=0:Then
"My world is Black & White. But if I blink fast enough, I see it in Grayscale."


Offline hellninjas

  • LV7 Elite (Next: 700)
  • *******
  • Posts: 625
  • Rating: +17/-0
    • View Profile
Re: xLIB-BASIC ERR:DIM
« Reply #7 on: September 15, 2013, 08:53:04 pm »
Code: [Select]
:ClrDraw
:16→X
:16→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/8)+1,(Y/8)+1)=0:Then
:¦ ¦ S→X:T→Y
:¦ End
:
:End

Repasted~

Offline tr1p1ea

  • LV7 Elite (Next: 700)
  • *******
  • Posts: 647
  • Rating: +110/-0
    • View Profile
Re: xLIB-BASIC ERR:DIM
« Reply #8 on: September 15, 2013, 09:18:24 pm »
You still have X then Y, Y needs to come first:

If [A]((Y/8)+1,(X/8)+1)=0:Then

Code: [Select]
: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]((Y/8)+1,(X/8)+1)=0:Then
:S→X:T→Y
:End
:End
« Last Edit: September 15, 2013, 09:23:27 pm by tr1p1ea »
"My world is Black & White. But if I blink fast enough, I see it in Grayscale."


Offline hellninjas

  • LV7 Elite (Next: 700)
  • *******
  • Posts: 625
  • Rating: +17/-0
    • View Profile
Re: xLIB-BASIC ERR:DIM
« Reply #9 on: September 15, 2013, 09:24:24 pm »
Problem solved!
eheh
Thanks a bunch you two :3