I'm making a TI-BASIC game, where the player can move around 2-D maps on the home screen. I make an 8x16 matrix for each map:
[[1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1]
[1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1]
[1,0,1,0,1,0,0,0,0,0,0,0,0,0,0,1]
[1,0,1,0,1,1,1,1,1,1,1,1,1,1,0,1]
[1,0,1,0,0,0,0,0,0,0,0,0,0,0,0,1]
[1,0,1,1,1,1,1,1,1,1,1,1,1,1,0,1]
[1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1]
[1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1]]
...and this "function" to display it:
For(A,1,8)
For(B,1,16)
Output(A,B,sub(" I",[A](C,D)+1,1))
End:End
Now, I have multiple maps (matrices) and need to "call" that function with a different matrix without re-typing that code every time. Is there a way to do this?
It is possible to pass an argument to a method using the Ans
variable. Here is an example (with prgmDISPLAY
based on your given display function):
prgmDISPLAY
For(A,1,8
For(B,1,16
Output(A,B,sub(" I",Ans(C,D)+1,1
End
End
You would then call this method by calling prgmDISPLAY
from the main program, like so:
[[1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1][1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1][1,0,1,0,1,0,0,0,0,0,0,0,0,0,0,1][1,0,1,0,1,1,1,1,1,1,1,1,1,1,0,1][1,0,1,0,0,0,0,0,0,0,0,0,0,0,0,1][1,0,1,1,1,1,1,1,1,1,1,1,1,1,0,1][1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1][1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1
prgmDISPLAY
Or, if the matrix is stored in [A]
, simply do:
[A]
prgmDISPLAY