Hardware Reference
In-Depth Information
run it either by using IDLE's Run Module option in the Run menu or from the terminal by
typing python raspberrysnake.py . he game will start as soon as it has loaded (see
Figure 11-6), so make sure you're ready!
Figure 11-6:
Playing
Raspberry Snake
on the
Raspberry Pi
A full copy of the program listing for Raspberry Snake is included in Appendix A, “Python
Recipes”, and on the Raspberry Pi User Guide website at http://www.wiley.com/go/
raspberrypiuserguide . Downloading the source code from the website will save you
some typing, but entering the code by hand is a good way of ensuring that you understand
what each section does. In addition to the functions used in Raspberry Snake, pygame pro-
vides lots of features not used in this program, including audio playback, sprite handling for
better graphics and mouse control. he best place to learn about pygame's more-advanced
functions is on the oicial website, http://www.pygame.org/wiki/tutorials , where
you can download tutorials and example programs to get a handle on how things work.
Example 4: Python and Networking
So far, you have learned how Python can be used to create standalone programs, but the
language can also be used to create programs that communicate with the outside world over
a computer's network connection. his next example, written by Tom Hudson, ofers a brief
glimpse of these possibilities with a tool for monitoring the users connected to an Internet
Relay Chat (IRC) channel.
Search WWH ::




Custom Search