Writing the Game¶
We’re going to write the program in four stages, some of which are broken into smaller stages:
- Create an empty game
- Get a ball to bounce around the screen
- Create a bat controlled by the user which the ball will bounce off
- Create bricks which the ball will knock out
At each of the steps you’ll be told what code to write. But there will also be suggestions to change things around, to try things out.
Also, at each stage, there will be an explanation of some the things which are happening, to help you understand what your code is doing.
At the very end, there will be ideas for how to extend the whole game, to add extra elements or make things more difficult or more interesting.
Running the Game¶
Because we’re using PyGame Zero to build our game, we’ll have to run it with PyGame Zero’s special runner, called pgzrun. If you’ve written Python before, using IDLE or another editor, this is different from what you’d normally do.
You write your game in an editor (IDLE or another one) and then you run it from a Terminal window by typing pgzrun wallball.py.
You can always quit a PyGame Zero game by pressing Ctrl+Q.