Game Programming: Coding for Fun 233
Wikimedia Commons
Figure 10-1: Atari’s famous Pong game from 1972
The gameplay for a single-player version of Pong is simple.
A paddle moves along one edge of the screen (we’ll place our
paddle at the bottom) and rebounds a ball, in our case a smiley
face. Players gain a point each time they hit the ball, and they
lose a point (or a life) every time they miss.
We’ll use our bouncing smiley face program from Chapter 8 as
the foundation for the game. Using SmileyBounce2.py (page 199)
as our base, we already have a smoothly animated smiley ball
bouncing off the sides of the window, and we’ve already taken
care of the while loop that keeps the animation going until the
user quits. To make Smiley Pong, we’ll add a paddle that follows
the mouse along the bottom of the screen, and we’ll add more col-
lision detection to see when the smiley ball hits the paddle. The
final touch will be to start with zero points and five lives, give the
player a point when they hit the ball, and take away a life when
the ball bounces off the bottom of the screen. Figure 10-2 shows
what we’re working toward. When we’re finished, our final pro-
gram will look like the one on page 243.