Translations of this page:

Step 008 - Animation

Remember the Subsurfaces from the last step? And remember that the snake had always the same grinning facial expression? Now, let's make some animated sprites1) - not pygame sprites, but surfaces that show different images of an animation cycle, like a bird flapping its wings.

Instead of painting all the single pictures of an animation cycle myself, I prefer to use ready-made sprite sheets.

In the data folder, you will find a spritesheet2) from Ari Feldmann's Spritelib ( ) showing several pictures of an animal. If you use Ari's sprite's, make sure to include his license information in your program.

With the help of pygame's subsurface command, I will show you how to extract single images from the sprite sheet and use them.

Code Discussion

Source Code on Github

To run this example you need:

file in folder download pygame Download the whole Archive with all files from Github:
Sprite sheet by Ari Feldman

View/Edit/Download the file directly in Github:

click reload in your browser if you see no code here:

Comment this Page

1) a 2d-object moving around is referred as a Sprite_(computer_graphics)
2) a graphic file with lots of sprites

en/pygame/step008.txt · Last modified: 2015/07/18 19:39 by Horst JENS