"For example, I have game level map layout, whith level numbers as well as level completion progress."
This can be stored as global variables or in an array. If you need any other advice you should give more details about the game and what data you are storing.
Hi —, thank you for your reply.
The map is scrollable up-down, with about 200 levels connected with roads between them. In principle, the most variables are levels and map resources (coins and energy), while other things are just aesthetic images.
There are various types of levels and every type have its own sprite. Every level have max 3 stars and every star is shown in accordance with player progress.
If we go with global variables for every level, would that mean a minimum of 200 global variables is needed for all levels? Isn’t that a lot of global variables just for that purpose, or is that fine?
So far I have tried 2 ways, one with level instance variables, because each level have more instance variables like LevelType, LevelNumber, LevelCompletion, etc., while second way is with arrays.
In first way I created all levels on layout together with instance variables. Then I put all levels into Family and and on start of layout all levels are chacked with For each level, etc.
While in second way I tried with Image points on Map background image and connected them with Array editor via AJAX and every layout start levels are creating based on array data and Image point positions. Then I save this array on Local storage.
Both ways give me the same result, but first way is faster and clearer for code, and second way is slower, with full of array commands insted sprite.variable, but easier for game saving and later comparation between levels.
I'm still trying to decide which way to go. Personally I prefer to work with arrays and dictionaries, but I also like and sprite instances.
What do you think, what should I do?