Omnimaga

Calculator Community => TI Calculators => Axe => Topic started by: Downsider on February 03, 2011, 12:40:02 am

Title: How should I store levels?
Post by: Downsider on February 03, 2011, 12:40:02 am
Okay. In my game, I currently store levels in 1024 bytes of data, making a 32x32 level. I store it like this:

[0101010101010101010101010101010101010101010101010101010101010101]
[0101010101010101010101010101010101010101010101010101010101010101]
...
[0101010101010101010101010101010101010101010101010101010101010101]->GDB0

The problem with this is that some tiles are destructable and it modifies GDB0's data directly. How can I have GDB0 reload from what I set it to when I launch the game again or when the player dies? Currently, the destroyed tiles stay destroyed, unfortunately.
Title: Re: How should I store levels?
Post by: Quigibo on February 03, 2011, 03:54:04 am
If this remains a program, and not an app, then you can can continue to use self modifying code by adding an extra buffer.  So lets say GDB1 is the unchangeable level and GDB0 is your level buffer (this is what you use in the game).

[...lots of level stuff...]->GDB1  .Your level data for level 1
[...lots of level stuff...]->GDB2  .Your level data for level 2
Zeros(1024)->GDB0       .Your buffer
Copy(GDB1,GDB0,1024)    .Copy all of level 1 into the level buffer
...Feel free to modify this now...
Copy(GDB2,GDB0,1024)    .Copy all of level 2 into the level buffer
...Feel free to modify this now...
Copy(GDB1,GDB0,1024)    .Reloads level 1 again, restored to normal like it should
...etc...
Title: Re: How should I store levels?
Post by: leafy on February 03, 2011, 03:10:38 pm
I was just wondering, how do you change tiles in the middle of the game?
Title: Re: How should I store levels?
Post by: squidgetx on February 03, 2011, 07:07:58 pm
leafiness0:
Code: [Select]
(New tile value)->{(Yposition of new tile) * (Width of level) + (Xposition of new tile) + (Level data start)}