Answer the question
In order to leave comments, you need to log in
What is the best way to store a game level map?
I am writing my game on Canvas + javascript (like Mario). I wondered about storing the level map, plus the coordinates of the enemies and so on. So I didn’t fully understand the simplest and most resource-intensive way. I downloaded a couple of games on github and the level map was stored in an object with the coordinates of each game object. It turns out that you need to measure the coordinates of each object with a ruler and then compare them? What is the best way to approach this issue?
Plus, the question is: what is the best way to unload these objects onto the stage, because if the character does not see the objects, then they are not needed in the game yet. That is, how to implement a better lazy load of objects?
Answer the question
In order to leave comments, you need to log in
If the game is simple, then you can store it like this in the form of a JS array, which lists:
1 - all objects,
2 - their type (enemy, mound, chest ...),
3 - their characteristics (where the enemy looks, how many lives are in the chest ),
4- their coordinates (where they are)
Of course, we also need the level map itself, to which the data from this array will be applied.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question