Sprite is a term from computer graphics meaning a two-dimensional visible object, that has been optimized for rendering. Pygame offers the
Sprite class that deals with sprites. It can draw sprites on a
Surface object. It also has collision functions. For complex games, we can group sprites together for easy management. Sprites are not thread safe, so you should take care when using multiple threads.
We will redo the animation demo, but this time with sprites and using
Rect objects, which represent rectangles. A
Rect object has
height attributes. We will use these and other attributes throughout the example. Also we will let the avatar spin when the mouse button is clicked. However, ...