Before you can use Pygame, you need to import it, in the same way you imported the random module in Chapter 12. We’ll also be using the sys, time, and random modules for this game, so we need to import them too.
One of the modules in Pygame is called locals, and we’ll use its
rect function for drawing rectangles, as well as some of its other features. So we don’t have to tell Python each time that the functionality we need is inside the locals module, we can import it in the second line of our program. It’ll save us time typing and make the program easier to read.
Here are the first two lines of our program:
# PiBuster from Raspberry Pi for Dummies
import pygame, sys, time, random
from pygame.locals import *