Author | Comment |
canissoft Probe Posted: 20 Oct 2007 22:20 GMT Total Posts: 1 | Hello guys, I saw some great games you made there and I just want to ask a question.
I have a TI-89 Titanium and I want to know how I can manipulate a matrix data set to create a map.
Here are the following things I am stuck on.
How do you use Display() to generate a map coded in matrix? I saw some 83 users use the For() command but I am not quite sure how it works in 89.
How do you recall the rows and columns of a matrix and change the values in order to create movement?
Thanks! |
Vectris Ultralisk
Posted: 24 Oct 2007 16:25 GMT Total Posts: 375 | Note: I have a 84 so this is how i do it, it should be the same for the 89 except i think it has a bigger screen.
to display the contents of a matrix type in
:Disp [A](Y,X or :Output(A,B,[A](Y,X
and it will display the contents of matrix A at whatever is in row Y and column X
as for the 'for(' command, they probably used it to display all of the contents of the matrix with a minimum amount of code and at a fast past, like so
:for(Y,1,8 :for(X,1,16 :Outupt(Y,X,[A](X,Y) :End :End
assuming that the matrix is of course 8x16 which is the size of the homescreen on my calculator and is the one most people use to make games. Now since matrices only store numbers you might want to translate the numbers in to letters for better "grahpics"
:for(Y,1,8 :for(X,1,16 :If [A](Y,X)=1 detect the number :"A"->Str1 turn that number into a letter :Output(Y,X,Str1 output the string with the letter :End :End
overall the 'graphics' or text will flow across the screen from left to right and top to bottom until your map is fully displayed |
Lunchbox Carrier
Posted: 24 Oct 2007 16:41 GMT Total Posts: 2007 | Matrices, however, are ridiculously slow when it comes to looping through them and outputting graphics in the way you've described. Use a string instead, and store all 128 characters you need for the map in the string and just say:
:Output(1,1,str1 where str1 is the string variable you have the map in. It works much faster. |
Vectris Ultralisk
Posted: 25 Oct 2007 19:29 GMT Total Posts: 375 | strs are instant, not just faster |
Lunchbox Carrier
Posted: 25 Oct 2007 22:56 GMT Total Posts: 2007 | Nothing on a calc is instant. Far from it, though by comparison, strings seem like it. |
Xphoenix Ultralisk
Posted: 20 Nov 2007 18:09 GMT Total Posts: 210 | Using output on the 89T with the row and column arguments will be at that location in pixels. You need to make sure that you evenly space the characters. I think the text it 6 by 8 pixels, but I'm not positive.
:For y,--,-- :For x,--,-- :Output y,x,matrix[y][x] :EndFor :EndFor Where matrix holds the different ASCII characters for displaying, because 68Ks are just that cool.
--- ~Xphoenix |