# Possible to draw isometric tiles with height and moving objects in one pass?

I am working on a isometric tile-based game where the tiles can sometimes have differing heights - representing elevation. I am trying to understand how to order the tiles for drawing when there are moving objects in the scene (for instance the player character).

I use a priority queue to order all my tiles by their screen position in y and x and z (in that order).

Therefore the draw order of my tiles is a diamond pattern (The screen x, y axes originate at the top left, the tile coordinates start in the middle of the top of the screen).:

  0
1 2
3 4 5
6 7
8


this will render the elevation correctly but suppose you have a player at location 4 that moves towards location 7 in the "SE" direction, now - while the PC is in motion it will be hidden underneath the background tile at location 7, because 7 is drawn after 4 and the player is moving from 4.

I can solve this problem by adding the player velocity unit vector multiplied by the distance to the next tile to the comparator for the priority queue and effectively moving the player's position in the draw order to come after 7 and before 8.

But now suppose there is a elevated "cliff" at location 6, the top side of the cliff should partially hide the player from view while he is at 4, but while the player is in motion, because the queue now places the player after 7, it will appear as if the player is "floating" on top of the cliff.

The only solutions I have been able to come up with to this problem involves drawing the tile at location 6 again, (effectively drawing it twice) so that the second instance appears to "cover" the player.

Here is a screenshot showing what I mean, in it the donkey is moving SE and rendering on top of the cliff instead of behind it:

• @agone, I edited the post, the screen xy coordinates start at the top left corner. Commented Oct 12, 2023 at 21:17
• Sort by Z first. Make sure that the player or donkey's Z value is in between the lower path's Z and the cliff's Z. Commented Oct 12, 2023 at 21:38