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

Re: [pygame] Using sprites versus simple surfaces



Tnx for the info. I should once play around with the sprite routines to get a feeling for it.

Am 13.11.2006 um 17:49 schrieb Pete Shinners:

On Sun, 2006-11-12 at 21:50 +0100, Farai Aschwanden wrote:
General question about using sprites in Pygame: Whats the big thing
of sprites in Pygame?

There's no big deal for Pygame sprite, it is entirely optional to use. It does provide a generic framework that should be able to handle any style of game. But since it is so generic it doesn't provide much direction.

Here's a few of the quick features I think are worthwhile.

1. Full dirty update rectangle handling. This is the biggest
optimization a nonscrolling pygame project can make. There are tricky
cases for dealing with it yourself, and you get it for free when using
the group with dirty rect updates.

2. Multiple group optimization. The sprites are designed to belong to
multiple groups. Use multiple containers to identify game objects
instead of attributes. When you need to look at all objects with a
specific property, you only look at the ones in the correct container.
You could use the groups to spacially divide objects, etc. Sprites are
designed to quickly come and go from different containers. They are
simple, but well optimized.


http://www.pygame.org/docs/tut/SpriteIntro.html