Game Development Stack Exchange is a question and answer site for professional and independent game developers. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

A tutorial that I have followed had me collect and blit all of my sprites with the following lines:

allsprites = pygame.sprite.RenderPlain((l_sprites))

At the moment, this is fine for me, as all of my sprites make use of the same base image. However, I find myself in need of having various sprites animated, some changing, and some going to a basic colored rectangle.

My question is if this batch drawing method is still viable when all of my sprites are in flux. My previous experience has been in straight C with SDL, and normally I would simply roll my own update loop.

share|improve this question
up vote 3 down vote accepted

The Group class (for which RenderPlain has been a deprecated alias for many years) is more a logical tool than a performance tool. It provides no speed benefit over looping over the sprites yourself. If you are constructing it every frame, it's definitely a net negative.

What you should do instead is replace your l_sprites list of sprites with a group directly. Rather than appending sprites to the list, add them to the group. This lets you use Group.update to update the sprites rather than rolling your own update loop. It also lets sprites remove themselves from the group using Sprite.kill, which is often a more convenient way to remove them.

If you want a performance gain out of using sprite groups, you should turn to RenderUpdates, which returns a list of rectangles appropriate for passing to pygame.display.update.

(If you want good performance, you should give up Pygame's sprite library and turn to OpenGL or one of its Python wrappers instead.)

share|improve this answer
I guess this can become a separate question...but OpenGL is better at performance than SDL? I've always been curious but never knew any background on the differences between the two (we did SDL in college) – espais Aug 5 '11 at 13:56

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.