Simple Sprite Routines Ease Handheld Gaming DIY

Making your own handheld games is made much easier with [David Johnson-Davies’] simple sprite routines for the Adafruit PyBadge and PyGamer boards. Sprites can be thought of as small, fixed-size graphical objects that are drawn, erased, moved, and checked for collision with other screen elements.

xorSprite() plots an 8×8 sprite, moveSprite() moves a given sprite by one pixel without any flicker, and hitSprite() checks a sprite for collision with any screen elements in a given color. That is all it takes to implement a simple game, and [David] makes them easy to use, even providing a demo program in the form of the rolling ball maze shown here.

These routines work out-of-the-box with the PyBadge and PyGamer, but should be easy to adapt to any TFT display based on the ST7735 controller. The PyGamer is the board shown here, but you can see the PyBadge as it was used to create an MQTT-enabled conference badge.

If you really want to take a trip down the rabbit hole of sprite-based gaming graphics, you simply can’t miss hearing about the system [Sprite_TM] built into the FPGA Game Boy badge.