Welcome, Guest. Please login or register. Did you miss your activation email?

Author Topic: Isometric Depth?  (Read 3117 times)

0 Members and 1 Guest are viewing this topic.

Nekroze

  • Newbie
  • *
  • Posts: 30
    • View Profile
Isometric Depth?
« on: December 20, 2012, 10:37:45 am »
I am working on a map engine for isometric tile based maps. I am thinking on how to draw the sprites and map tiles in the right depth order.

I have made my own implementation of a vertex array with all kinds of extra features just for drawing isometric tile maps such as being able to draw for Y[0] to Y[1] so i was thinking i could store each drawable object in the game in some kind of depth sorting class that divides the screen into screen height / tileStepY (if a isometric diamond is say 32 pixels height then the step is 16 pixels) and then sorts the sprites by their bottom of their shape (the feet) into a bunch of arrays for each depth division. This way when i move a sprite in the map i just have to give its new foot position to the depth sorting class and it would move it to the correct depth division.

This would allow me to draw the map tiles for each depth division and then the sprites that need to be drawn next then goes to the next depth and draws the tiles of the map for that division then the draw that depths sprites. I can optimize this to detect depth divisions with no sprites so i can draw multiple depth divisions of the map tiles at once.

My question is, as i have no idea how this is normally implemented and have come to this style on my own, is this a bad idea or are there any problems anyone can see that i may run into later? I am not sure as well if i should store all active sprites in a overall array and then use its indices or something as an ID and use that to reference that drawable/sprite in the depth arrays or what but that is another issue.

How would you do isometric depth sorting/drawing?

Gregory

  • Newbie
  • *
  • Posts: 41
    • View Profile
Re: Isometric Depth?
« Reply #1 on: December 25, 2012, 06:58:09 am »
I'm trying to do it now and my solution is use a priority queue with pairs that contains a pointer to a sf::Drawable and a unsigned int that represents the depth. I made own classes with drawing members that when invoked, instead of draw in the RenderWindow,  it pushs to the queue. The queue will be sort by depth, so at the end of the "step" I draw all the content of the queue.