RustScape
A compact and robust 2D video game for the NUCLEO-F411RE, written in Rust.
Author: Mihnea Girbacica
GitHub Project Link: https://github.com/UPB-PMRust-Students/project-Mihnea8848
Description
RustScape is a 2D platformer game that aims to deliver a classic handheld gaming experience on a minimal embedded system. It's built for the NUCLEO-F411RE development board, pushing the boundaries of what's possible with microcontroller-based game development. Graphics are rendered on a vibrant 1.8" SPI TFT display (ST7735R), reminiscent of retro handhelds, while player control is achieved through an analog joystick and D-Pad Shield combo (KY-023) for movement, being a perfect choice for achieving that "retro feel". To complete the immersion, two passive buzzers provide a very makeshift soundtrack for the game and chiptune-style audio feedback. In the spirit of the DIY ingenuity, the project tries to embrace a cost-effective approach, even aiming to house the final product within the NUCLEO-F411RE's original cardboard shipping box. In the final version of this project, the players should be immersed in the game's story, overlooking the... less than desirable appearance and cheap parts.
Motivation
As the owner of a Game Development Company, I've been fascinated by video games since childhood. The curiosity to understand their creation has always driven me. While my current work involves developing cross-platform titles for PC, Android, Linux, and VR (see https://www.roblox.com/games/3192370355/MEH-Studios-Research-Facility-Test-Server for more details), I've always held a particular fondness for retro games and the challenge of emulation. This project, with its requirement to use microprocessors, presented the perfect opportunity to combine my passion for game development with the exploration of embedded systems, allowing me to create a physical, playable tribute to classic handheld gaming. With that being said, due to the limitations (Flash Storage Space), it forces me to fix my habit of writing spaghetti code, leaving optimizations at last, or even skipping them altogether.
Architecture
To be added at a later time, the hardware is still not fully configured.
Log
Week 5 - 11 May
The main goal of the first week was to make all of the peripherals work.
Code Changelog:
- Created the Cargo.toml, with all the required dependencies
- Created module display_module.rs, that integrates the ST7735s display to the microcontroller
- Created module sound_module.rs, that integrates the 2 Passive Buzzers (one for Bass and one for Melody) to the microcontroller
- Created module controller_module.rs, that integrates all of the SHIELD buttons to the microcontroller.
Hardware Changelog:
- Decided to use the cardboard shipping box of the NUCLEO-F411RE as the chassis of the project
- Test fitted the following parts to the box: ST7735s, 2x Passive Buzzer, Fundruino SHIELD
- Glued inside of the box a small 3V3 and GND bus, taken from a small breadboard
- Tested the placement of the buzzers so that the soundtrack can be heard easily
Photos:
Week 12 - 18 May
This week is still to come, to be added.
Week 19 - 25 May
This week is still to come, to be added.
Hardware
RustScape is built using the NUCLEO-F411RE development board, which acts as the game's central processing unit. Visuals are rendered on a 1.8" SPI TFT display. Player input is managed via a shield integrating an analog joystick and buttons, enabling movement and actions. Audio feedback is delivered through two passive buzzers, generating sound effects and simple music. Jumper wires ensure flexible electrical connections. Power and code uploads are facilitated by a Mini-USB to USB-A cable. Finally, an 8-LED module is used to represent the player's health status. All components, including the NUCLEO-F411RE board, are housed within the original NUCLEO-F411RE box, serving as a budget-friendly enclosure for the handheld console.
Schematics
The KiCAD Schematic is not yet finished, below is an unfinished version.
Bill of Materials
Device | Usage | Price |
---|---|---|
STM32 NUCLEO-F411RE | Microcontroller that drives the peripherals, as well as game logic | 70 RON |
1.8" SPI TFT Display | 128x160 Color screen that displays the game | 29 RON |
KY-023 Analog Joystick | Joystick + buttons for player movement | 20 RON |
2 x Passive Buzzer | Audio feedback and soundtrack for the game | 2 RON |
Mini-USB to USB-A Cable | USB Cable for power and code flashing | 4.5 RON |
Jumper Wires | 2 x Male-male & 1 x Female-female Cables | 17 RON |
8 Red LED Module | 8 LEDs to display the player health | 11.5 RON |
Software
Library | Description | Usage |
---|---|---|
embassy-stm32 | HAL for STM32 | Abstracts the NUCLEO-F411RE's hardware (SPI, GPIO, Timers) for easier control. |
embassy-executor | Asynchronous runtime | Enables non-blocking operations for smooth gameplay. |
embassy-time | Asynchronous timing | Provides delays and timing for game logic and display updates. |
display-interface-spi | SPI display interface | Handles low-level communication with the ST7735R. |
mipidsi | ST7735 driver | Offers display initialization and control. |
embedded-graphics | 2D graphics library | Draws shapes, text, and other visuals on the screen. |
defmt | Logging framework | Provides efficient debugging output. |
panic-probe | Panic handler | Improves error handling during crashes. |
cortex-m-rt | Cortex-M runtime | Sets up the microcontroller environment. |