So I'm thinking about making an Adventure style game and I was wondering how you would store more than one room into a matrix, and what the code would be to load a new room but also save all the progress made in another room.
Well there are multiple solutions here. There isn't such thing as a 3d matrix on the calculator, but you have a few options, some more advanced than others.
1) A matrix can be no larger than 20x20. I'm imagining you probably want a matrix of 16x8, but if you had smaller rooms you could probably fit 4 small rooms in the same matrix. This is probably not a very useful option.
2) You can use multiple matrices, but there are only 10 which are [A] [B] [C] [D] [E] [F] [G] [H] [I] and [J].
3) If you want to store multiple rooms in the same matrix, you can put fractional parts at different decimal placements for separate rooms. But that can be difficult for a newcomer and I don't have the time to go into that at the moment.
4) You can use lists (even your own custom lists if you want, but that can be slower), and assuming your rooms are 16x8 then your lists would equate to 128 elements long. This would require some reworking with your math, as checking neighbors would require you to go up or down the list different amounts whether you are checking the neighbor up left right or down. But with a list you could have speed improvements, memory saving improvements, and you can separate the list into rows by going every 16.
You could also use fractional parts for different rooms with lists if you want.
5) You could use one entire list for up to 7 different rooms. 16x8=128, so 128*7=896 and you couldn't have an eighth room in the same list because that would surpass 999 elements, the maximum amount of elements you can have in a list. Your list would have each different room 128 elements apart, and each row 16 elements apart. You could use this, but it could also maybe be a bit difficult for a new programmer.
I'd say the best option right now for you is to use the 10 different matrices the calculator has, but if you think you want to tackle any of the other options just let me know.
Thank you, I really appreciate the advice. I think for my game either using lists to storerooms or using different matrices would probably work out. I was wondering what the code would be if I used to Matrix route, or the list route if you would know what the code would be to load a new room but also save progress in previous rooms for either solution.
Sorry for the late response, not a lot of time lately.
I don’t know what your code is specifically, but the matrix route should not be difficult. I don’t see why you’re thinking you would need to save the matrix/room before going to a new one, because your new room as I suggested would be using matrix [B] an then [C] and so on. The matrix doesn’t need to be saved as any updates you make to it are permanent until you update it again. But, I also don’t see why you would be changing your matrix if it’s just a map of walls.
Your character doesn’t need to be in the matrix, you should just have an A and B value for where it is on the screen, and check that against the matrix walls.
Thus, when your character moves to the desired position to go to a new room, just keep track of what room your in currently, then use code in your game to go to [B] or [C] or whatever, and display the walls from that matrix on screen.
To keep track of rooms and what matrix to use, you could for example set a variable to 1 for room [A], then change it to 2 if you’re going to room [B], and so on.
So would it make sense to store matrices [A]-[J] into a list so collision detection can be applied to the whole list? and if so what would that code look like?
You're making it confusing.
Can you please show what your code is that you've tried so far?
"A matrix can be no larger than 20x20."
I am concerned about where this information came from. On the the 83+/84+ (the topic in question), matrices can have either dimension up to 99, and the other constraint is the amount of free RAM available.
Anyways, one thing that I used to do was store the code for a matrix in a program. It is usually much smaller that way memory-wise, and I can unarchive the program, execute (all it does is store the matrix), then re-archive if I am strapped for memory. Note that the only way to archive/unarchive a program in pure TI-BASIC is via a glitch. Otherwise, you'll need to use a small assembly hexcode (and I'd you are using hexcodes, I'd use TPROG or COPYPROG instead of the slow unarchiving/archiving process).
Z80 Assembly>English>TI-BASIC>Python>French>C>0
Maybe it's different on the other calculators, but there is always, I mean always a Memory Error on the TI 84+ CE when you try to make a matrix larger than 20x20.
Just for clarification, matrices can be up to 400 cells, whether 4x99 or 20x20.
🧟Initiating Project Horde 🧟
It is limited by the amount of free RAM you have. Take free RAM, divide by 9, and subtract 2 for good measure. That's how many elements you can fit. For example, if you have 18000 bytes of free RAM, then you can fit 18000/9-2 = 1998 elements.
Z80 Assembly>English>TI-BASIC>Python>French>C>0
Hey I was wondering since this is a friendly & active chat, if someone could help me with a question about the Ti-inspire cx? I’m currently taking Business & Finite math mathematics and we are in the last 4th section over linear programming. Currently we are going over the Matrix simplex method & pivoting and I cannot figure out how to find/used or even download a Smplx programming on the nspire cx that I am using. I do not have a Ti-84/83 at my disposal. Can you help me?
While I do appreciate all the insight you all have given me, I still feel like my original question was never answered: If I stored individual rooms into each matrix ([A]-[J]), what would the code be to load each room once the previous room is finished, and how could I code collision detection that could apply to all rooms without typing out individual code for each matrix. I am not mad or frustrated, it is simply just a request. Thank you and I seriously appreciate the help.
To use a single collision detection, you would have to have a matrix reserved to be the "Active" level. This means that matrix [A] for example would be the active room, and [B]-[J] would contain the data for each room. The basic concept is that as you move the player around the screen, the corresponding value in the matrix gets checked. Lets say you have a 1 represent a wall, 0 represent empty space, 2 represent a key, and then 11-19 representing which room you go to when you walk through that space. Then, when player presses an arrow key to move:
- If the space they would move to is a 1, don't move them
- If it is a 0, move them
- If it is 2, move them and add 1 to a variable
- If it is 11, move them and load matrix [B] into [A], then redraw the screen
- If it is 12, move them and load matrix [C] into [A], then redraw the screen
- So on and so forth for each matrix
It is extremely difficult to write code for other people without a basis to work off of, and it is best practice for you to write your own. It is, after all, your idea for the game. If you need examples of code, I can try and dig some up, but it is highly unlikely they will be exactly what you are looking for.
Yeah, there is no one way to do it and I'm pretty sure most people just come up with their own techniques. Lately, I've been using the technique of adding, say, 100 to a tile number, and if the tile is ≥100, it triggers an event when you walk on it. As well, tiles that are out-of-bounds return 100 so that when you walk off the map, then your code treats it as an event and runs some map-specific code (for example:
If M=1
Then
If X=20
Then
2→M
prgmLOADMAP
End
If X=6 and Y=9 and not(⸤SAVE(3
Then
1→⸤SAVE(3
"YOU FOUND THE SECRET KEY!
prgmDIALOG
End
End
That's just a BASIC pseudo-code; you would have to make your own prgmLOADMAP and prgmDIALOG on your own code to read/write tiles and figure out what different tiles do.
NOTE: I see that there is an unrecognized character in the code box; that is the "list 'L'" or "little 'L'" used for custom lists. In the pseudo-code, it is treating the 3rd list element as a flag indicating if the player already has a key or not. BASIC pros might not do it quite this way, but it is easier this way in BASIC.
Z80 Assembly>English>TI-BASIC>Python>French>C>0
I do believe this example that you provide is something similar to what I'm looking for, I'm just wondering what the code would look like if the space the player lands on is two, load matrix [B] into [A] then redraw the screen. The code I originally referenced to make a single level was the collision detection example mentioned under movement in the TI 83 Basic guide if that helps. I do appreciate all the help and I apologize if I have made this anymore difficult than it needs to be.
Note: My last response was a response to Trenly27's example.
Similar to Xeda’s Example, you would hve to make your own code to draw maps onto the screen. There are many different ways to do this depending on your level of expertise
//Movement code here
//Assuming A and B are players position
If [A](A,B)=2
Then
[B]->[A]
prgmLOADMAP
End
//rest of program
Thank you, I really appreciate the help. I believe this example will work perfectly with my code. I appreciate everyone's help and I apologize if I was being difficult in any sort of undesirable way.
I just have one more question if it's okay with you all. For rendering the map I'm using this code:
:For(C,1,8
:For(D,1,16
:Output(C,D,sub(" IW",[A](C,D)+1,1))
For right now in my code I'm using a subprogram (LoadMap) simply just to store one map into one matrix. Would it also make sense to include the code to render the map in that subprogram or just keep the actual rendering in the main program, and in addition would it make sense to include the code that stores [B] and all other matrices after that into [A] in that same subprogram? I know this thread is slightly old but since this was the original thread where I asked my original question, I thought It would make sense to add it to here.
Any of those variations seem fine to me, but if you want to use matrices bigger than 8x16, it might be easier to have either a separate program render the portion of the map, or render it in the main program.
Z80 Assembly>English>TI-BASIC>Python>French>C>0