Before I begin, I want to say I am certainly not an expert in ti-basic, but for a guy who just learned the repeat command, I got ambitious.

Within the past thirty days, I have been working on a ti-basic program that I like to call "Traverse." An X traverses through the 16 x 8 grid (formatted by a matrix) and when the player walks to a "portal" space, the game loads the corresponding map for the player to appear on the other side (an extremely-basic-Zelda-One type of scrolling if you will).

The problem is the only thing I can find on mapmaking without using pxl commands is a maze level from the "ti-basic starter kit: movement" on this site. I found that this program would end when the player went on top of a "2" tile because of it's coordinate position, so I set to reverse-engineer the code by (a) rearranging the numbers so that the player is in a sort of walled in area whilst (b) inserting DISP. ANS into the code to see how the code analyzed coordinates. I found to my dismay, however, that the program analyzed the numbers in a columned fashion; the code made no distinction between the top and the bottom of columns in the matrix.

So I'm rather stumped as a whole. I don't really want to go the simple way by reworking the matrix so that the top exit is in a different column than the bottom exit.

After modifying the before-mentioned code, here's the code I ended up with:
(Note: It doesn't have to be a matrix, it's just that there's an option on my calculator that makes matrices bizarrely simple)
(2nd Note: This is not how far I've gotten, but it works. The code I'm working on is much messier)

Is there any way that this could be fixed so that the code signifies both the row and column coordinate and not just the column itself? Is there a more efficient code than this? Any help will be dearly appreciated.

Havent tested this, but this should do basic movement with matricies. A is the row, B is the column

//Draw the matrix
For(C,1,8
For(D,1,16
Output(C,D,sub(“ X “,[A](C,D)+1,1
End
End
4->A:7->B //set the starting location of the player
Output(A,B,”O //show the player
While not(sum(K={45,105,21 //repeat until clear, enter, or delete is pressed
Repeat sum(K={24,25,26,34,45,105,21 //repeat until an arrow, clear, enter, or delete is pressed
getKey->K
End
If (A>1)(A<8)(B>1)(B<16)(sum(K={24,25,26,34:Then //if its an arrow key and wont push out of the map bounds
Ouptut(A,B,sub(“ X “,[A](A,B)+1,1 //erase the player
A+(K=25)-(K=34)->A //update the players coordinates
B+(K=26)-(K=24)->B
Output(A,B,”O //Redraw the player
End
End

I was bored and decided to make this working example. Here are the variables:

L: A flag which tells if the map has been loaded
S: A variable used to keep track of the active map
A: The players "Y" coordinate
B: The players "X" coordinate
M: A flag which tells if the map has already been changed
K: The key last pressed
C: A variable used when drawing the map
D: A variable used when drawing the map

Code (indented and commented for clarity):

//set the starting position of the player, the starting map, and the load status
0→S:0→L
4→A:8→B
DelVar K
//This is the main game loop. Exit the game when Clear, Enter, or Delete is pressed
While not(sum(K={45,105,21
//If the map has not been loaded to the screen
If not(L:Then
//Load the map into the matrix
If not(S:[[1,1,1,1,1,1,1,2,2,1,1,1,1,1,1,1][1,1,0,0,0,0,0,0,0,0,0,0,0,0,1,1][1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1][2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2][2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2][1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1][1,1,0,0,0,0,0,0,0,0,0,0,0,0,1,1][1,1,1,1,1,1,1,2,2,1,1,1,1,1,1,1]]→[A]
If S=1:[[1,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,1,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][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][1,1,0,0,0,0,0,0,0,0,0,0,0,0,1,1][1,1,1,1,1,1,1,2,2,1,1,1,1,1,1,1]]→[A]
If S=2:[[1,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,1,1][1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1][2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1][2,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][1,1,0,0,0,0,0,0,0,0,0,0,0,0,1,1][1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1]]→[A]
If S=3:[[1,1,1,1,1,1,1,2,2,1,1,1,1,1,1,1][1,1,0,0,0,0,0,0,0,0,0,0,0,0,1,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][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][1,1,0,0,0,0,0,0,0,0,0,0,0,0,1,1][1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1]]→[A]
If S=4:[[1,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,1,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,2][1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2][1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1][1,1,0,0,0,0,0,0,0,0,0,0,0,0,1,1][1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1]]→[A]
//Display the map
ClrHome
For(C,1,8
For(D,1,16
Output(C,D,sub(" X ",[A](C,D)+1,1
End
End
//display the player
Output(A,B,"O
//store that the map is loaded
1→L
End
//wait until a key is pressed Clear, Enter, Delete, or Arrows
Repeat sum(K={24,25,26,34,45,105,21
getKey→K
End
//if it was an arrow key: movement condition
If sum(K={24,25,26,34:Then
//replace that portion of the map
Output(A,B,sub(" X ",[A](A,B)+1,1
//move the player with collision detection
A-(K=25)(A>1)([A](A-(A>1),B)≠1)+(K=34)(A<8)([A](A+(A<8),B)≠1)→A
B+(K=26)(B<16)([A](A,B+(B<16))≠1)-(K=24)(B>1)([A](A,B-(B>1))≠1)→B
//redraw the player
Output(A,B,"O
//if in a portal : portal condition
If [A](A,B)=2:Then
//say the map has not been changed yet
DelVar M
//if on the main map
If not(S):Then
//change which map we are on based on the portal entered
If A=1:1→S
If B=16:2→S
If A=8:3→S
If B=1:4→S
//say the map was changed
1→M
End
//if the map hasn't been changed yet
If not(M:Then
//determine which map we are on
//Note the A= and B= are not necessary if there is only one portal on each map. But, if there
//is more than one portal, use the coordinates to determine which portal was entered
If (A=8)(S=1):0→S
If (B=1)(S=2):0→S
If (A=1)(S=3):0→S
If (B=16)(S=4):0→S
End
//Update the players coordinates
//Note that you will need to change this section if the portals are anywhere but the edges
If A=1:7→A
If A=8:2→A
If B=1:15→B
If B=16:2→B
//set the flag so the new map gets loaded
0→L
//End the portal condition
End
//end the movement condition
End
//end the main game loop
End
//clear the homescreen to remove the map
ClrHome
//delete the matrix, since its the only large variable
DelVar [A]