• Hey Guest! Ever feel like entering a Game Jam, but the time limit is always too much pressure? We get it... You lead a hectic life and dedicating 3 whole days to make a game just doesn't work for you! So, why not enter the GMC SLOW JAM? Take your time! Kick back and make your game over 4 months! Interested? Then just click here!

Z-Order sorting

jujubs

Member
So I've followed this very classic post by like100bears on doing fake 3D using 2D sprites. It works very well. However, when my objects start overlapping, they seem to appear onscreen on the order that I've put them in the room. I'm drawing a few columns and they just appear on top of the ones that should be in front.

How could I go about fixing this? I thought about sorting objects by height on the Y axis, but I have no idea on how to go about that.

I also want to rotate the room, and I'm 90% that the rotation will mess everything up again even if I find out how to sort it like this.
 
D

dannyjenn

Guest
What I did in the past was, I made all the instances invisible, and then I made a single controller object with a draw event which would place all the instances into a priority queue (based on their distances from the camera), then pull the instances out one at a time, and draw each one accordingly. Since the furthest one is always the one to be pulled out first, they end up drawn in the correct order.

My way doesn't seem all that efficient, but I do not know whether there is a better way. Maybe someone else could suggest something different.
 
Last edited by a moderator:
i thought you were going for a kind of depth sorting method, like often used for bird's eye viewed games, depth = -y. If so, then you can still do it with a rotated view. Not sure if that will solve all your problems since you don't have a screenshot of your game up.
 
Top