Chapter 10. Game Time

 

One of the great traditions of learning to program is typing in code you don’t understand. Really!

Sometimes just typing in code gives you a “feel” for how things work, even if you don’t understand every line or keyword. We did that in chapter 1, with the number-guessing game. Now we’re going to do the same thing, but with a longer, more interesting program.

Skier

Skier is a very simple skiing game, inspired by a game called SkiFree. (You can find out all about SkiFree here: en.wikipedia.org/wiki/SkiFree.)

You ski down a hill, trying to avoid trees and pick up flags. Picking up a flag earns 10 points. Crashing into a tree makes you lose 100 points.

When you run the program, it should look something like this:

Skier uses something called Pygame to help with the graphics. Pygame is a Python module. (We’ll learn more about modules in chapter 15.) If you ran the book’s installer, Pygame is installed. If not, you can download it from www.pygame.org. We’ll learn all about Pygame in chapter 16.

There are some graphics files you’ll need to go along with the program:

skier_down.png skier_right1.png
skier_crash.png skier_right2.png
skier_tree.png skier_left1.png
skier_flag.png skier_left2.png

Try it out