Section 1 – imports, globals, and drawings
In this first section, we will write all of the code to set up the different parts of our game. This includes importing libraries, defining all of our global variables, and telling the computer how to draw the screen, ball, and paddles.
Importing libraries
The first lines of code we write will be used to import the necessary libraries into the game, including pygame. We will be using three libraries in the game: pygame, math, and random. pygame, as we discussed in the previous chapter, allows us to have visual elements in our game. The random library, included with Python, gives us the ability to select and use random numbers in our game. The math library, also included with Python, allows for mathematics with floating point numbers. To use these modules and libraries in your code, type the following lines into your tiny.py
file underneath the #imports, globals, and drawing comment:
import pygame import random import time
Tip
Make sure to save your...