[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

Re: [pygame] sprite engine



Geekius Maximus wrote:

Cindy,
I am currently working on a sprite rendering engine as well, and I
really appreciate that you're passing these ideas around, they've
been really helpful. I have just one question for you, though. How
do you get the images to blit in a specific order? Do you have
one class containing all of the sprites, which blits only the
dirty sprites and those that are blitted on top of the dirty sprites?


The same method Droid uses - maintaining a list of sprites in back to front order on the screen. Whenever something is added, removed, or position changes, I resort the list.


I've done it both ways - a single parent containing multiple children, which can themselves contain children, all of which are drawn in order from the root child... and my old method where nothing was a 'child' of anything, it was almost all a single flat list. My latest work is using the parent/child relationship, which I like better... but the main gist of any method is, you must maintain a list somehow, somewhere, that the main render loop renders. And even in my current parent/child structure, I must keep the sort order correct - so I'm still maintaining the list Droid mentioned he uses, as well.

--Kamilche