Revisit the arcade classic Pong in Python
Calvin Robinson takes us through creating a contemporary homage to Pong - considered by many to be the very first arcade game.
Calvin Robinson
OUR EXPERT
Calvin Robinson is a subject matter expert at the National Centre for Computing Education, and a computer science teacher.
This series of building retro games in Python has so far seen us coding a lunar landing space module, a side-scrolling platformer, the famous pellet-munching, ghost-chasing Pac-Man, and in this issue we’re going to develop our own version of Pong!
To many, Pong is the original arcade game. It’s certainly the first video game to become a commercial success. Released for arcades in 1972 and for the home in 1975, Pong was gained popularity worldwide and is now permanently memorialised in the Smithsonian Institute in Washingon DC. Developed and self-published by Atari, Pong is a 2D table tennis simulation with arguably the most simplistic game design imaginable, while managing to achieve an incredibly addictive gaming experience.
What gameplay?
Gameplay mechanics in Pong are quite simple. It’s essentially ping-pong seen from a basic birds-eye view. The game makes use of vector graphics to display a rectangular shape for the players’ pads and a square (or rough circle, depending on the processing power) for the ball.
In single-player mode, the player moves one paddle and the computer acts as a non-player character, controlling the second. The idea is to get the ball to pass the opponent’s paddle on their side of the screen. You earn a point for each time the opponent misses a rally. Atari’s Home Pong console was set up for two-player mode, with a paddle for each player. That’s the version we’re going to create today. Since we don’t have hardware and we’re programming this entirely in Python, we’ll give each player two keys on either side of the keyboard: one for up, one for down.
Python offers us an accessible programming language with straightforward syntax. It’s the perfect language for playing around with vector-based video games. Let’s go!
One of the first home video game consoles: Atari Pong.
Ping-pong Python
Without getting into any debates about version 2 versus version 3, we’ll be using Python 3 for this tutorial. If you’re running a Debian based Linux distro you can install Python in Terminal with the command sudo apt- get install python3 after a quick update with sudo apt-get update , of course. We’ll also be taking advantage of a vector graphics module linuxformat.py from last issue. This can be found on the disc, or via the source code link on our Archives page at www.linuxformat.com/ archives. Once downloaded or copied, ensure linuxformat.py is saved in the same directory as the rest of the files we create in this tutorial.