Hi folks
I am attempting to create a 2D isometric “game engine” as a hobby project using SDL2 and C++.
I am using isometric sprites published by KenneyNL - e.g.:
https://kenney.nl/assets/isometric-buildings-1
An issue I'm encountering is that the (linked) building tile sprites comprise both the base tile and the building (vertical) component; because of this, I cannot find the strategy I need to implement to enable proper sprite ordering during render time.
Specifically:
- Sprite sorting using Y coordinate: when the sprites are rendered in the order they appear on the Y axis (e.g. from their top middle or bottom middle point), sprites which should appear “on top” (e.g. cars) are occluded by tiles which appear further down
- Sprite ordering using Y coordinate AND a “z” index: attempting to address this issue by introducing a “z index” (e.g. by forcing cars to be drawn after tiles) may result in:
- Tile z_index=0; building tile z_index=0; car z_index=1: the car is drawn “on top” of the vertical portion of the building
- Tile z_index=0; building tile z_index=1; car z_index=1: the car and the building's vertical portion are rendered in the “correct” order - but the building tile's base component is rendered “on top” of tiles appearing further down
I will attach some images below to illustrate what I mean.
My question is, is there some accepted approach rendering this popular tileset in the correct order?
Thanks in advance


