I am currently working on a 2D RTS game (tiled based and oblique projection). I wanted a way to only draw the entities that are currently on screen, my first instinct was to store the entities in an array, then check through that array, to see if any entities where inside the camera view, and if they where draw them.
However, this will become taxing to do if there is a large amount of units and/or players (enemy), as it would have to sort through the hundreds(ish) of times a second. My second, thought was to store them in a two dimensional array (according to their X and Y values), then use a calculation based of the camera position, to start/stop drawing the entities only in the camera view (this is pretty much the same process I use to draw the map's tiles).
This method has the advantage it would be a lot easier to draw, as I wouldn't need to sort them according to their Y Value (so units could over lap each other (again, oblique projection)). The only real downside is when entities start moving around the map, they would delete each other if they walked through each other(although could be prevented). Also, to me at least, it seems a bit long winded.
Does anyone else have any suggestions/alterations?
Thanks a lot!