I'm working on a roguelike and would like to know how to structure my map data. I suppose this question could also be extended to any sort of top down 2d game. Anyways! My game will contain object types like terrain, doors, switches, monsters, and items. How should the objects be stored within a map?
Some ideas I've gathered online:
- The map is a 2d array. Each cell in the array can store multiple references to objects occupying it.
- The map contains several layers of 2d arrays, and each layer stores references to objects of a specific type.
- Like 1. but only store static terrain information in the 2d array. The rest of the objects are dynamic and stored in lists for each type.