Developers' Diary

Paraplu: Ordered Layers!

Whoa, I just completed the ordered layer drawing system. Before, all Guys on a particular layer were drawn in whatever dang order the game pleased. This was fine in Soft Landing, because it had a purely side-on view and it was unlikely to matter which of any given pair of peers on a layer draws in front of the other. But Paraplu has a kind of hybrid top-down and side-on view, like A Link to the Past. So when two Guys overlap, it’s important for the one that’s higher up on the screen to appear behind the one that’s lower down.

Python made this pretty easy with its custom comparison functions for sorting. These ordered layers just use this loop for drawing:

for oneGuy in sorted(layer.sprites(), cmpY):

Instead of this one:

for oneGuy in layer.sprites():

And the cmpY function is just this:

return -cmp(a.rect.bottom, b.rect.bottom)

Super simple! Thanks, Python and Pygame!



2 responses to 'Paraplu: Ordered Layers!'.

Comments and pings are currently closed for 'Paraplu: Ordered Layers!'.