11 MIN READ TIME

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.

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.

Unlock this article and much more with
You can enjoy:
Enjoy this edition in full
Instant access to 600+ titles
Thousands of back issues
No contract or commitment
Try for 99c
SUBSCRIBE NOW
30 day trial, then just $9.99 / month. Cancel anytime. New subscribers only.


Learn more
Pocketmags Plus
Pocketmags Plus

This article is from...


View Issues
Linux Format
Summer 2020
VIEW IN STORE

Other Articles in this Issue


In This Issue
Soft Mints, no Snap
“Won’t people think it’s 20 years old?” management asked when
REVIEWS
Robolinux 11
RoboLinux is a project that we’ve been meaning to look
Calculate Linux 20.6
Back in Elizabethan times, “calculating” used to be a crime,
Besiege
Besiege is notionally a game about engineering medieval siege weapons
Waveshare Game HAT
We heard you like playing games from yesteryear, so how
ROUNDUP
Integrated Development Environments
Mats Tage Axelsson is happiest when writing how to make
MINT 20
Summer is well upon us and what better way to
INTERVIEW
MAINFRAME MAGE
John Mertic is director of program management for the Linux
OPEN SOURCE UNDERGROUND
Those of you who want to exercise your mind and
Pi USER
UBUNTU Pi
The official Canonical-supported desktop flavour of Ubuntu for the Pi
OpenVX lands on Raspberry Pi
This Raspberry Pi thing is all getting very serious. Clearly,
Magnify via Pi
The High Quality Camera for the Pi has been available
Aging Vulkans
We’ve reported that the Pi 4 will be gaining an
Learn how to program the 50 pence chip
Mike Bedford discovered PICs many years ago and felt an
REGULARS AT A GLANCE
A new generation of Linux-only PCs
Something unusual is happening in the world of computing: companies
Maintain the maintainers
The Linux Foundation has had its annual shindig at Open
Microsoft Linux Defender
Microsoft is hoping to boost its security protection for Android
BETTER CALL MATT
Matt Yonkovit is Percona’s chief experience officer and a member
SKY HIGH
Keith Edmunds is Tiger Computing Ltd’s MD, which provides support
NEWSDESK
Google is getting a taste of the education market and
Distro watch
A 64-bit live system designed for USB flash drives and
VIRTUAL PLUMBING
2020 has been, and continues to be, a redefining year
LINUX ON APPLE’S ARM
Jon Masters has been involved with Linux for over 22
Kernel Watch
Linus Torvalds has announced the release of Linux 5.8. He’s
ONGOING DEVELOPMENT
Peter Oskolkov posted patches titled Introduce FUTEX_SWAP, which attempts to
Your free downloads
To replace our regular covermounted DVD we’re offering five top
Answers
In looking at the new printers from HP and Epson,
Mailserver
Your “Unpeeling the Onion Browser” article (LXF264, June issue) was
Intel Core i9-10900K
We’re long past the days of monolithic chip designs. Now
Audacity
Shortly after Mike Bedford’s excellent hands-on Audacity tutorial in LXF264,
Ksnip
Three years ago, we said that Ksnip was a promising
PDF Quirk
Modern Linux desktops are mostly a pleasure to use, yet
Apostrophe
There are at least a dozen various text editors for
Pidgin
The usual path for Linux and Windows users that need
QEMU
Virtualisation software is a dream come true for distro-hoppers, because
Bauh
We’re living in a world where traditional package managers (such
Blobby 2
Blobby Volley 2 is a great head-to-head beach volleyball game
JFDuke3D
There are many theories why Duke Nukem 3D has become
Parachute
The cornerstone of desktop productivity is being able to work
Wihotspot
How do you share a Wi-Fi connection in Linux? Well,
TUTORIALS
Record video using motion detection
Jonni Bidwell is fairly contrary. His garden grows with silver
Find your files in Broot
Shashank Sharma is a trial lawyer Delhi. He’s been participating
Multi-user task and project management
Nick Peers has spent most of the past few months
Configure Proton for enhanced gaming
John Knight When he’s not running away from Australian snakes
Develop video games with the Godot engine
Calvin Robinson is a subject matter expert at the National
Chat
X
Pocketmags Support