[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [pygame] layered surfaces



Karl Boehnker wrote:
> What I'm trying to do--at least conceptually--is have layers of surfaces 
> (maybe sprite groups?) being manipulated independently by different threads.
> The desired effect being that when I clear and update sprites on a higher 
> layer, the cleared section uses as a background all the lower layers, even
> if they are changing too.

doing 'layers' of sprites will be easiest with multiple rendering 
groups. i wouldn't worry about maintaining multiple background 
layers. every frame clear all the sprites, and then draw each layer. 
this should work fine, even if there are a lot of nonmoving sprites 
(which i guess the 'multiple backgrounds' would try to optimize)

also, if you are using RenderUpdates, make sure the group that you 
draw with, is also the group that clears the sprites.


as far as your ideas of threading. be a bit careful with this. 
pygame's audio and events are threadsafe, but it is up to you to 
keep the graphics threadsafe. you really should only access the 
display from the 'main' thread. you might need to do some of your 
own syncing to make sure all the objects are in a 'drawable state' 
when the other thread goes to render.






____________________________________
pygame mailing list
pygame-users@seul.org
http://pygame.seul.org