Pi images. (Supposedly, it takes about 4×17 raspberries to make a full-sized raspberry pie.) The
game uses a dictionary to create the different raspberry images and keep track of their current
locations and individual offset settings.
Each image must be clicked with a mouse to be eliminated. The game ends when all the raspberry
images have been removed from the game screen. Figure 19.4 shows how the game looks in action.
FIGURE 19.4 The Raspberry Pie game in action.
You can make a number of changes and improvements to the Raspberry Pie game script. The
following are a few suggestions of changes you can try to further your adventure in learning:
Create a “quit” option to leave the game using a keyboard sequence of keys.
Add a game header to the game screen.
Make each raspberry “pop” and disappear when it is clicked.
Draw a hot baked pie image at the end of the game.
Rewrite the Raspberry Pi images as objects instead of dictionary entries.
Game script writing really lets you be creative. Hopefully this small list of suggested changes will get
you started writing your own Python game scripts.
Summary
In this hour, you read about various Python game frameworks. You learned how to load and use the
PyGame library to create game scripts. You got to write a couple simple games, add sounds to the
game, and create player interaction with moving game images. In Hour 20, “Using the Network,” you
will expand your Python knowledge and learn about networking with Python.