I coded my own Centipede on a Raspberry Pi with a book, and it reignited my love of coding

I coded my own Centipede on a Raspberry Pi with a book, and it reignited my love of coding

Published Dec 3, 2026, 6:00 AM EST Former radio and TV guy (I Heart Radio and PBS). Now a writer, researcher, and musician who writes about the absurdity of our modern world and other offbeat topics. Specializes in weird music, the old web, retro video games and tech, and researching strange, yet interesting things. His work has appeared in Vice, Tedium, Star Trek.com, Today I Found Out, Typebar, SyFy Wire, and How To Geek. Currently working on a variety of music, web, and writing projects. Visit him on the web at https://djbuckfreelance.neocities.org/. I used to be really into retro games and single-board computers (SBCs). Over the past year or so, I’ve been revisiting those twin obsessions with a metric ton of retro gaming and a few Raspberry Pis being added to my collection/home lab. I’m still in the process of re-learning stuff and became quite intrigued by a recent Humble Bundle full of Raspberry Pi project books. In particular, a book called Code the Classics caught my attention. It’s a book that shows you how to code versions of classic arcade games. When I saw it, I said, “Heck, yeah! I’m in!” to no one in particular. My dog glanced in my direction, a look of boredom on her face. My wife chuckled and turned away. I booted up my Raspberry Pi and turned to the chapter on Fixed Shooter games. Then I started to code, with fantastic results. Fixed shooters are among my favorite types of games Centipede is the greatest game of all time I adore a good retro gaming project. Code the Classics is a remarkable book that not only includes projects for building these games, but also has a lot of history and backstory. It’s fun to read even if you’re not actively coding something. I dig that. I chose to code a fixed shooter because I always loved playing them in the arcade, on the Atari, and, later, on my NES. Centipede is a personal favorite (my favorite version is actually the Atari 7800 port, believe it or not). I like to try different variations of it, and seeing it as an option in the book made me immediately say, “This is the one I’m coding.” I’d argue Millipede is a fantastic follow-up, but it doesn’t quite hit me the same way Centipede does. Anyhow, the book was easy to follow, and I got started pretty quickly. A simple way to get started with retro coding It’s like a crash course in retro programming Although the book provided the base code, it thoroughly explained how every element works. For example, the Game class creates enemies, the insectoid creature itself, and a lot of the rocks that appear throughout the playing field. The update and draw functions read the state variable and run code that’s relevant only to the action currently happening on the screen. I felt something click in my mind as I read this and ran the code myself. The code itself includes comments that explain how things work. For instance, the movement grid is explained in depth. After reading it, I understood how it worked: the directions variable and each letter corresponding to a direction. It's a great foundation for building future projects. I made a version of Centipede called Myriapod using this book. Myriapod is intended as an homage to Centipede and plays much like it. It’s pretty straightforward. And it only took a few hours to build and customize. Coding a classic game variation Coding so simple, a dummy like me can follow along For this project, the book has the reader using Python to make the games. It's based on a template, so it's simple for beginners to get started. That's perfect for me, because I'm in the process of learning Python. So I started with the code provided in the book. Then I customized it a little. The book has a URL for downloading the game code and assets, but my browser flagged it as a bad link (the domain probably just expired). So, just to be safe, I used the Raspberry Pi Press repository containing the book's codebase and assets. I grabbed the assets from the GitHub repo and got started. The folders contain a Python file called myriapod.py, which contains all the base code and notes for the Pygame Zero version of the game. I ran the base version using a virtual environment first: python3 -m venv .venv source .venv/bin/activate pip install pygame It didn't want to work at first. There was an error. I forgot that I needed to install Pygame Zero to get it to work. I even mentioned it a paragraph ago, so whoops! I used pip install pgzero to get the ball rolling. I launched it with python3 myriapod.py and played a bit. It looked great, and if you have a Raspberry Pi, you may recognize it. So now the fun part: making it my own. I figured I'd try adding a rapid-fire mechanic and changing the tank into something else. For the custom rapid fire, I set up a rapid fire boost ability using RAPID_FIRE_DURATION and RAPID_FIRE_COOLDOWN on Player. They’re two separate things. The boost activates every 500 points. The cooldown sets the frames between shots. These weren’t included in the book’s example code, but I learned a lot from another resource, the Pygame Zero docs, as I moved along. There is a noticeable difference in rapid-fire ability between the original and custom versions. That was a fun adjustment. For the final touch (and just for the heck of it), I replaced the tank with a very low-res HTG logo. I'll definitely tweak this custom version in the future as I learn more about coding with Python, but this was a terrific start. Having a blast with the classics I can’t overstate how much of a blast building and playing this game was. I did not expect that. I learned a lot with this project, and it’s reignited an interest in coding that I thought had been lost to time. Overall, this was a fantastic and fun way to dip my toes into coding a game, and I’m enthusiastic about doing more Raspberry Pi-related and gaming-adjacent projects.

Original Source

Read the full article at Howtogeek →

KhanList aggregates and links to publicly available news content. We do not host full articles from third-party sources. Always verify important information with original sources.