Linux Format

Adding gamepad support to Tetris

OUR EXPERT

Andrew Smith is a software developer at NHS Digital, and has qualifications in software engineering and computer networking.

T his month, we going to look at a Tetris project that’s been written in Python, and then add code to support an Xbox One controller. In theory, the code should work with other PC-based compatible controllers, but they’ve not been tested for this tutorial and so may require some adjustments and configuration changes. Your millage may vary!

Before starting this tutorial, we advise plugging your game controller (if you have one) into your computer and making sure that it works with your distro of Linux (we’re using Ubuntu). This tutorial is based on a Tetris project originally created by Luke Arnston – see www.pygame.org/project/133/166.

Tetris, a graphical puzzle game first created in 1984 by Alexey Pajitnov, it has since become available on multiple platforms and implemented using a range of programming languages. One of the most popular platforms that this video game was available on was the Nintendo Game Boy, which was released in the late 80s/early 90s. The Game Boy was a relatively cheap, hand-held device that could be easily packed away and taken and played anywhere.

involves players creating lines from shapes (Tetronimoes) that descend gradually into the game playing area. These shapes can also be manipulated (moved left to right and rotated) to fit in with other shapes to create a complete line. Once a complete line is created, the line then

You’re reading a preview, subscribe to read more.

More from Linux Format

Linux Format1 min read
Vector Vexations
Why does MySQL not support vectors in its community edition? Generative AI is the hot topic in tech. GenAI relies on vector data. Yet Oracle has no plans to support vectors in the community edition of MySQL. If you want to try out vector data with ot
Linux Format5 min read
Tips For Managing Docker Containers
Everyone knows how containers revolutionised application building and deployment. Using a E disposable stack of containers that make up an app that aren’t using the docker-compose command to manage the stack are missing a trick. It allows the shippin
Linux Format1 min read
Wine For Wayland
2023 was a great year for the Wayland driver for Wine. The goal was to move forward from the experimental phase and make the driver a proper upstream component. A year later, after several merge requests, many people are now already able to use the l

Related