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

Re: [pygame] optimization for my sprite rendering



solitare0@netscape.net wrote:
Sorry for the verbose post (but it's late and I've been working on this
for too long) and thanks for any help you can give me in advance.
i'd start by using the RenderUpdates sprite group. This can do exactly what you want (i think) by clearing only the changed parts of the screen. You'll need to change your code so the background is not a sprite, but handled separately.

the RenderUpdates class has a "clear()" method that takes a background. It will draw the background only underneath the sprites. The "draw()" method for RenderUpdates returns a list of rectangles representing all the areas onscreen that have changed. You can pass that list to pygame.display.update() for the fastest frame switch possible.

When you do change you background image you will just need to draw the entire thing, and call pygame.display.update() to draw and update the entire screen. After that you can continue on normally.