I am making a 2D RPG game in Monogame XNA. For the moment I have 2 kinds of data in my game: sprites objects and tiles.
All the sprites are contained in a array list. I iterate over the sprites ArrayList to update and draw each sprites. Sprites objects are sort by their Y positions before each draw. This way, my character and other enemies can walk behind sprites. Sprites can be anything that require player interaction for example: chest, tree, enemy, player…
Tiles represent inanimate objects(2D array) (object that you cannot interact with) and only used for collision data and have a basic animation system.
However, for sprites collision checking I have to iterate over every sprites to do a bounding box overlap check.
My system works well, but I want to simplify things. What if I store static objects in my 2D tile array? I could just do getTile(x,y)
to get the object stored in that position instead of going through my array list.
In the future I would like to have several types of objects, weapons, projectiles, and I want a consistent way to organize this.