Game Development Reference
In-Depth Information
17 - Graphics and Animation
you how to use the Pygame library to make games with graphics, animation, and sound.
In these chapters we'll find source code for simple programs that are not games but
demonstrate the Pygame concepts we've learned. Chapter 20 will present the source code
for a complete Pygame game using all the concepts you've learned.
A software library is code that is not meant to be run by itself, but included in other
programs to add new features. By using a library a programmer doesn't have to write the
entire program, but can make use of the work that another programmer has done before
them. Pygame is a software library that has modules for graphics, sound, and other features
that games commonly use.
Installing Pygame
Pygame does not come with Python. Like Python, Pygame is available for free. You will
have to download and install Pygame, which is as easy as downloading and installing the
Python interpreter. In a web browser, go to the URL http://pygame.org and click on the
"Downloads" link on the left side of the web site. This topic assumes you have the
Windows operating system, but Pygame works the same for every operating system. You
need to download the Pygame installer for your operating system and the version of Python
you have installed (3.1).
You do not want to download the "source" for Pygame, but rather the Pygame for your
operating system. For Windows, download the pygame-1.9.1.win32-py3.1.msi file. (This is
Pygame for Python 3.1 on Windows. If you installed a different version of Python (such as
2.5 or 2.4) download the .msi file for your version of Python.) The current version of
Pygame at the time this topic was written is 1.9.1. If you see a newer version on the
website, download and install the newer Pygame. For Mac OS X and Linux, follow the
directions on the download page for installation instructions.
Figure 17-1: The pygame.org website.
On Windows, double click on the downloaded file to install Pygame. To check that
Pygame is install correctly, type the following into the interactive shell:
>>> import pygame
Search WWH ::




Custom Search