It doesn't matter that much how often you blit something to the screen surface, since the display does only get updated once you call pygame.display.update
or pygame.display.flip
.
If you're sure that blitting the whole background image to the screen surface is a bottle neck in your game, you can try the following things:
a) Instead of blitting the whole background every frame, use the clear()
function to "erase" your sprites from the screen.
b) Instead of calling pygame.display.flip
or pygame.display.update
without an argument, call pygame.display.update
with the list of the areas on the screen that have been changed, which is returned by the draw()
function (maybe in combination with clear()
).
c) Create your display surface with the FULLSCREEN
, DOUBLEBUF
and HWSURFACE
flags.
But as I already said: make sure you know where your bottle neck is. Some common performance pitfalls are: loading images multiple times from disk, font rendering, using different pixel formats (e.g. not calling convert
/convert_alpha
on surfaces created from images) and generally the lack of caching.
(also note that python/pygame is generally not the first choice when creating graphically demanding games)