Page 1 of 1

Z-Ordering and ATL

Posted: Fri Apr 19, 2013 4:07 am
by joseph.brower
I'm using ATL, and am getting the hang of it now (and really enjoying it). I am curious about the best way to handle z-ordering though. I have a character in my game, and I want to make sure that the drawing order is correct. I see how to draw the layers in different orders, but I don't see any way to gracefully handle drawing my characters and such at the right time. Anyone have any ideas or pointers?

Re: Z-Ordering and ATL

Posted: Fri Apr 19, 2013 4:33 pm
by adnzzzzZ
What's ATL? Anyway, I've written about this here.

The basic idea is to sort your objects list every frame according to some criteria. For a Zelda-like game (not top-down at a 90 angle) that criteria would be the y attribute of the object's position. For a platformer you could have an additional z attribute and then you sort it based on that, which is basically what you do when you use layers.

But yea, sort the objects such the ones that should appear in front of all others are at the back of the list and the ones that should appear behind everything are at the front. So that when you draw all objects going from front -> back they'll be drawn at the appropriate order.

Re: Z-Ordering and ATL

Posted: Sat Apr 20, 2013 1:36 am
by joseph.brower
https://github.com/Kadoba/Advanced-Tiled-Loader That is "ATL" I understand the concept of it. :) I'm just wanting to see if there is an elegant method for doing this.

Re: Z-Ordering and ATL

Posted: Sat Apr 20, 2013 10:01 pm
by Kadoba
It depends on how you structure your maps. Layers will always be drawn all at once in order. But object layers can be converted into custom layers that can be drawn however you want, z-order included.