While there are several guides on making some basic games in CircuitPython, they are meant to get you started with writing your own games. In this guide, I'll go over making a more complex tile-based game that had originally been available for the Lynx and Microsoft Windows 3.1 as part of the Microsoft Entertainment Pack 4. The version that this code is based on is the Microsoft version.
Instead of building upon displayio for the most part, this game takes a more traditional approach and uses CircuitPython's bitmaptools
module to draw the graphics directly to the screen buffer. This includes some more unique features, such as keyboard input from the keyboard buffer. This allows input from either the serial terminal or using an attached keyboard for a standalone setup.
The code is mostly based on Pocket Chips Challenge, which I had originally written for the Pocket PC using C++ in the early 2000s, and Tile World, which was written in C. Pocket Chips Challenge was never completed, and rewriting it in CircuitPython allowed me to finish the game. I could reuse most of the graphics I had made at the time, which were written for a 240x320 display. This includes a custom set of 24x24 pixel tiles, which I had redrawn based on the original 32x32 pixel tiles. The only graphics from the original game were the digits displayed on the right side.
Because of the limitations of writing it for a microcontroller, I had to find some creative ways to get the game to operate as quickly as possible. Originally I had written the game to use Double Buffering, and although the graphics were smoother, it just took too long to write to 2 buffers per frame and the game felt laggy. I ended up writing the game to keep track of tiles that changed and only performed partial screen updates.
The most challenging aspect of writing the game in CircuitPython was the lack of prebuilt dialogs and I ended up making these myself. I leaned fairly heavily on the adafruit_display_text library for displaying the text. It has come a long way since it was originally written, including bitmap labels which allow putting the text right onto a bitmap and text boxes which improve upon that by allowing horizontal alignment of the bitmap labels.
There are many more techniques that I used to make this, including working with paletted bitmaps, which had challenges of their own. This and many more techniques will be covered in more detail. This ended up being one of the largest pieces of code written specifically for CircuitPython that I'm aware of, so the code will not be listed in its entirety, but there are many great techniques to cover.
Parts
Because the size of this game is so large, you will need the version of the Metro RP2350 with 8MB of PSRAM. If you already have the version of the Metro RP2350 without the PSRAM and are comfortable with surface mount soldering, it is possible to solder on a PSRAM chip yourself to upgrade it.




Optional Parts
You will need a display with an HDMI input capable of displaying resolutions as low as 640x480.

or

If you would like to save the state of your game, you will need a microSD card.


Audio Output Parts
To add Audio Output, you will need a Digital-to-Analog-Converter and some extra parts to connect it




Additional Parts for Standalone Project
To make this project a standalone system, you will need the following additional parts.



or


Page last edited April 09, 2025
Text editor powered by tinymce.