A pyramid of stars!
I decided it wasn't worth getting bogged down on throwing in too many features into the spriting code yet - I won't know what I'll need until I need to make a game with it. So I just put in the basic minimum to get working functionality. The game code can set a sprite's:
- type (what it looks like)
- position (absolute or relative)
- rotation (absolute or relative)
- scale (absolute or relative again), and
- depth (once again, absolute or relative)
The depth is the special one of those cases, as it's the factor that determines what order the sprites need to be rendered in. For now I've got the graphics code resorting the sprite list every time the depth is changed for a sprite. When I get to speeding up the spriting code I'll tinker with some variants on insertion sort routines to see if this can be improved, but it works for now.
The sample image above shows 121 star disc sprites arranged in a grid. Without the depth code they'll be ordered in accordance with when they were created. With the depth code but left the starting depth of zero these disks are in a slightly random order (which suggests the std::list::sort routine isn't standard insertion sort - what are they using instead?). As shown in the image, each disk is given a depth equal to the Manhattan distance (that is, the sum of the vertical and horizontal distance) from the centre of the screen, which puts the centre disc on top. I've made smaller depths be closer to the screen than larger ones, the idea being the deeper something is the more buried it is.
I've decided to cancel the collision detection and physics part of the engine, since I feel that's far better to develop with an application in mind rather than just as a general engine. For now I'll get the absolute bare minimum features required to build a simple game up and running. This means I need basic animation services and text before moving from graphics to timers, input and audio.