202 Chapter 8
that Pygame has a different coordinate system from the Turtle
library, with the origin (0, 0) in the upper-left corner of the screen
and positive y-coordinate values as we move down.
You learned how to create animation by drawing objects on
the screen, clearing the screen, and then drawing the objects in
a slightly different location. We saw that the pygame.time.Clock()
object could make our animations steadier by limiting the num-
ber of times our animation draws each second, which is called the
frames per second, or fps.
We built our own collision detection to check for objects “hit-
ting” the edge of the screen, and then we added the logic to make
objects look like they’re bouncing back by changing the direction
of their speed or velocity variables (by multiplying them by −1).
Programming the cool apps in this chapter has given us the
skills to do the following:
• Install and use the pygame module in our own Python programs.
• Explain the structure of a Pygame app, including the setup,
game loop, and exit.
• Build a game loop that handles events, updates and draws
graphics, and updates the display.
• Draw shapes to the screen using pygame.draw functions.
• Load images from disk with pygame.image.load().
• Draw images and objects to the screen with the blit() function.
• Create animations by drawing objects to the screen repeatedly
in different locations.
• Make animations smooth, clean, and predictable using a
pygame.time.Clock() timer’s tick() function to limit the number
of frames per second in our animations.
• Check for collision detection by building the if logic to check
for boundary cases, like a graphic hitting the edge of the
screen.
• Control the horizontal and vertical speeds of moving objects on
the screen by changing the amount of movement in the x- and
y-directions from one frame to the next.