123
-=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- (c) WidthPadding Industries 1987 0|687|0 -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=-
Socoder -> Basic Basement -> Z ordering

Fri, 24 Jun 2016, 14:11
Dither
I have a bunch of game objects* -- player, enemies, bullets, etc. -- some of which are stored in structured linked lists (a list of enemies, list of bullets, etc.)

Each of these objects is of a structured type containing a field to store its y coordinate.

I would like all the objects to be drawn in ascending order from lowest y coordinate to highest (i.e. drawn from top to bottom of screen).

I know how to sort an individual list...but how would I deal with objects across multiple lists, and some that might not be in a list at all?

Thanks for your time.

*Not using "object" in the OOP sense.
Fri, 24 Jun 2016, 14:15
GfK
Make a new list, with a new type of object containing image handle, x, y, scale, rotation, all the rest of it. When something has to be drawn, just create an object with the required info and put it in the list instead.

Then when you're done, sort the list by y-coordinate, then just iterate through and draw them all in one hit.

That's how I'd do it.
Fri, 24 Jun 2016, 14:21
Dither
Brilliant, thanks, GfK! I will give that a try and let you know how it goes.
Sat, 25 Jun 2016, 13:30
Dither
Worked perfectly, thanks again for your help.