xxii
■INTRODUCTION
How This Book Is Structured
Beginning Game Development with Python and Pygame is divided into 12 chapters, each of
which builds on the previous chapter—with a few notable exceptions. I’ve structured it so that
you can get results quickly and see something on screen, which you may appreciate if you are
as impatient as I am. Virtually all the listings are self-contained, and hopefully entertaining, lit-
tle projects that run independently. Since experimentation is the best way to learn, you are
encouraged to play with the sample code and modify it to produce different effects. You can
also use any of the code in your own projects—with my blessing!
The first two chapters introduce the Python language in a fairly conversational manner.
If you read them with a Python prompt in front of you, you should find you can quickly pick up
the language. These two chapters don’t make a complete language tutorial, but will cover
enough for you to be able to understand the Python code in the book and write some of your
own. Occasionally, new syntaxes and language features are introduced in the rest of the book,
but I explain them where they are first used. If you are proficient in Python, you can skip
straight to Chapter 3.
Chapter 3 is your first introduction to Pygame and covers its history and capabilities. It also
explains the basics of setting up a graphical display and handling events, skills that are essential
for any game. You will become intimately familiar with the code introduced in this chapter, as
it is used in all the sample code for the rest of the book.
Chapter 4 dives straight into creating visuals and the various ways in which you can draw
to the screen with Pygame. Chapter 5 explores the techniques that game programmers use to
make those images move. You should find the discussion on time-based movement to be par-
ticularly valuable, as it is essential for any kind of animation in a game.
Chapter 6 tells you all you need to know to interface your game with virtually any gaming
device. The sample code in this chapter will have you moving a character around with the key-
board, mouse, and joystick.
Chapter 7 is a little unusual in that it is more self-contained than the others and doesn’t
depend as much on previous chapters. It covers the subject of artificial intelligence and
includes a fully working simulation of an ant’s nest, but the techniques I explain in this chapter
can be used to add seemingly intelligent characters to any game.
Chapters 8 and 9 are a gentle introduction to working with three-dimensional graphics in
Pygame, which is an essential topic since most games have 3D elements these days—even if
they are not full 3D games. I explain the math in visual terms that make it easier to grasp, and
you should find that it is not as an intimidating a subject as it first appears.
Chapter 10 takes a break from 3D graphics to discuss how to use Pygame to add sound
effects and music, and even includes a fully working jukebox application.
The final two chapters build on Chapters 8 and 9 to advance your knowledge of 3D graph-
ics, and explain how to take advantage of the dedicated game hardware on your graphics card.
By the end of Chapter 11 you will have enough knowledge to render and manipulate a three-
dimensional object on the screen. Chapter 12 explores several techniques you can use to create
even more impressive 3D visuals and generate special effects.
In addition to the 12 chapters, there are two appendixes: Appendix A is a reference to the
Game Objects library that is used throughout this book, and Appendix B explains how you can
package your game and send it to others.
8725.book Page xxii Wednesday, September 26, 2007 8:08 PM