To build our game, we will use the Pygame library, which provides a set of readymade functionality that we can use to build Pong and its animations.
Today, you will be using Repl.it to build the Pong game.
If you would like a re-cap on how to use Repl.it, check out the following Python basics tutorial
Next, let’s explain further some of the code that has been provided to you in the
Libraries and import statements
Look at the top of the code. You will see the following line:
This statement allows us to import all of the animation and object drawing functionality provided by the
pygame library. A library is a place where related functionality is grouped together for use in the Python language. For example, the
pygame library provides a way to draw a rectangle on screen, which we can use to draw the boundaries, the ball, and the paddles used in Pong game.
The gray line that starts with
# is called a comment. These are notes in the code that helps to explain what is happening in plain English. Comments are ignored by the computer; developers use comments to communicate with eact another especially when several developers are working on the same code. Comments also allow someone who is looking at the code to understand what is happening without having to read the code directly.
main.py we use comments to indicate where we need you to make changes to the code.