Hey guys n' gals,
I have a query relating to the ordering of sprites in a 2D tile-based scene.
Within the 'active viewport', I have something in the region of 14 x 8 tiles visible. This tile map consists of a number of overlaid elements.
First, there's the floor tiles - which get rendered first starting from the top-left, working row-by-row until it reaches the bottom-right of the viewport.
Second, I render the wall objects using the same draw method as above.
However, when it comes to active sprites, I'm a bit flummoxed as to how I order them with the correct depth without having to make lots of unnecessary texture bind switches.
Here's a quick n' dirty visualisation of what I mean:
Sprites need to be able to overlap each other on the 'z' plane (bottom to top), but it seems like the only way to do this is to check every sprite each time I draw a tile to find out if it should be at that exact depth. With potentially many sprites visible on the screen at one time - wouldn't this be tremendously slow? I'm sure I'm thinking about this wrong.
Any advice would be most appreciated. Thanks!