How can I store data for a Star Coin (New Super Mario Bros) collectible system ?

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By dingadev

Hi everyone !

I’m working on a game in which you can collect three collectibles in each level, it’s a system similar to the Star Coins you can find in New Super Mario Games.

I made a script for the Star Coins which emits a signal to a LevelScript every time a Star coin is collected and updates the GUI depending on which one is collected.

At the beginning of each level I set the value of each Star Coin is_collected to false and it works fine.

My problem is : I would like my game to store the collected Star Coins for each level, so that the player can later restart the level and get the ones they missed. And currently it is not the case, as the amount of collected Star Coins are passed on to every level.

I am not sure how I should proceed : I’ve read online that making a list, store each Star Coin ID then check which one is collected might be the solution. I’m currently trying to implement this but I feel there is another, more dynamic way to solve this issue. That’s why I’m posting this question.

I haven’t provided the code because I don’t find it relevant for this issue, but I’ll gladly share it if required.

Thanks in advance for your help!

:bust_in_silhouette: Reply From: Inces

I also believe, that stable dictionary is the way to go. I can’t see how dynamic is it supposed to get, since the problem is just about storing stale data.
This single dictionary should reside in highest scope of your project, eventually in autoloaded script, because it should be possible to access from every level and menu.

Thank you for answering, I’ll try to see how to implement that into my code and see how it works.

Thanks a lot!

dingadev | 2022-07-30 20:53

1 Like

Hello ! I’m trying implementing the same system in my game, but i have some issues. Can you show the piece of code responsible for storing data and check, please ?