you can check this demo's code
many games don’t save anything. in jelpi for example, when you collect a diamond or fruit, the game updates its internal variables to remove it from the world (so that it’s not drawn anymore) and to count it in the current inventory. this is reset when you restart.
to save things between runs, you can use cartdata/dget/dset to save and retrieve numbers. it’s up to your code to define for example that the number in slot 1 is number of hearts (1 to 3), the number in slot 2 is coins, etc.
docs: https://www.lexaloffle.com/dl/docs/pico-8_manual.html#Cartridge_Data
I’ll add that none of this is specific to platformers, all games do that. this tutorial is really great and has some collectable keys that open doors: https://www.lexaloffle.com/bbs/?tid=35135
See https://www.lexaloffle.com/dl/docs/pico-8_manual.html#Cartridge_Data (as mentioned above)
Use cartdata("your_unique_cartdata_id_here")
to initialize a cartdata save file in your user's environment.
Then use dset(index,yournumber)
where index
is an integer from 0 to 63 to store a number variable yournumber
.
Then you can use dget(index)
for that same index to retrieve the number even after the cart has been reloaded.
Are you trying to save information between reboots?
Or are you just talking about keeping track of items during a single run?
"Like when a character collects an item how is it store acrossed parts of the game?"
Maybe you just want to know how many coins you've picked up. Please clarify.
[Please log in to post a comment]