
PixelRoot32 Game Engine
A lightweight, modular 2D game engine for ESP32 and PC
Overview •
Features •
Demo Projects •
Tool Suite •
Quick Start •
Best Practices •
Documentation •
Roadmap •
Changelog •
Contributing •
License •
Credits
📖 Overview
PixelRoot32 is a lightweight, modular 2D game engine written in C++17, designed primarily for ESP32 microcontrollers, with a native simulation layer for PC (SDL2) to enable rapid development without hardware.
The engine follows a scene-based architecture inspired by Godot Engine, featuring kinematic controllers, scene transitions, camera effects, and deterministic gameplay systems tailored for embedded hardware.
🧠 Engine Philosophy
PixelRoot32 is not the product of a traditional electronics expert or a large engineering team.
It was born from curiosity, experimentation, and a deep love for retro games from the 90s.
Coming from a mobile development background with limited experience in C++, this project represents a leap into embedded systems. This was made possible by how accessible knowledge has become today—especially with AI-assisted tools lowering the barrier to building complex systems.
PixelRoot32 is a reflection of that shift: exploring new domains driven by curiosity rather than specialization.
At its core, the engine is built around a few simple ideas:
- Determinism over convenience
- No hidden costs (no runtime allocations, no magic)
- Simplicity and explicit control
- Performance as a core constraint
- Retro-inspired design with modern practices
👉 Learn more: Engine Philosophy
Demo in Action
Watch PixelRoot32 running on ESP32 with example games:

Click the image to watch the full demo on YouTube.
✨ Key Features
- Cross-Platform: Develop on PC (Windows/Linux/macOS) and deploy on ESP32.
- Scene-Entity System: Intuitive management of Scenes, Entities, and Actors.
- High Performance: Optimized for ESP32 with DMA transfers, IRAM-cached rendering, and a Dirty Regions pipeline.
- Sprite System: Support for 1bpp/2bpp/4bpp sprites with multi-palette selection, flipping, rotation, and animation.
- Tilemap Support: Optimized rendering with viewport culling, static layer caching, multi-palette, and tile animations.
- Tile Animation System: Frame-based animations (water, lava) with O(1) frame resolution and zero-allocation policy.
- Scene Transitions: Built-in Fade, Iris, and Diagonal Wipe transitions with configurable effects and ESP32-optimized rendering.
- Camera Effects: Deterministic camera shake, punch, and offset effects designed for low-resource embedded hardware.
- Independent Resolution Scaling: Render at low logical resolutions (e.g., 128x128) and scale to physical displays (e.g., 240x240).
- NES-Style Audio: Dynamic 8-voice subsystem with a fixed 4+4 partition (melodic tracks vs percussion/SFX), advanced SFX synthesis (loops, sweeps, breakpoint envelopes,
playSfxBank), and fixed-point No-FPU optimizations (Pulse, Triangle, Noise, Sine, Saw).
- Lightweight UI: Label, Button, and Checkbox with automatic layouts.
- AABB Physics: Godot-style physics with Kinematic/Rigid actors, one-way platforms, moving platform support, floor velocity inheritance, and custom hitboxes.
- Gameplay Framework: Opt-in building blocks — grid space, state machines, object pools, an event bus, interaction triggers, room graphs, camera tweens, depth sorting and spatial queries — each behind its own
PIXELROOT32_ENABLE_* flag, all default 0.
- Dialog System: Headless dialog state machine (
DialogRunner) with paged text, branching and conditional choices, multi-column option rows, multi-format speaker portraits in a fixed size box, and a default DialogBox panel — opt-in behind PIXELROOT32_ENABLE_DIALOG.
- ESP-NOW Networking: Optional router-free peer-to-peer module with an ESP-NOW transport and a native loopback, broadcast discovery, per-message reliable delivery (ACK/retry/dedupe), a Scene event hook, and a convergent shared counter with reboot resync - opt-in behind
PIXELROOT32_ENABLE_NETWORKING (default 0).
- Persistence (Save/Load): Optional module that separates storage models from media - named key-value settings and numbered save slots with typed results, a CRC-checked record envelope, ESP32 NVS, an opt-in ESP32 microSD (FAT) save-slot adapter, native host-file and in-memory adapters - opt-in behind
PIXELROOT32_ENABLE_PERSISTENCE (default 0), with the card adapter behind PIXELROOT32_ENABLE_SD_STORAGE (default 0).
- Indexed Color Palettes: Optimized palettes (PR32, NES, GameBoy, PICO-8) with multi-palette support.
- Modular Architecture: Compile only needed subsystems via
PIXELROOT32_ENABLE_* flags to reduce firmware size.
💡 Detailed info: Check out the Full Feature List.
🎮 Demo Projects
PixelRoot32-Demo-Projects is the companion repository: 31 complete,
self-contained projects you can copy, build and play.
Every demo is a standalone PlatformIO project that builds against the
published release from the registry — copy the folder anywhere, run
pio run -e native, and you have a working starting point.
How it differs from examples/ in this repository: the
examples here are eleven minimal projects, each isolating a single engine
capability, and none of them is a game. Read an example to learn one API; read a
demo to see several of them working together in something finished.
👉 Browse the demo catalogue
🧰 Tool Suite
The PixelRoot32 Tool Suite is a native desktop app (C++17 / SDL2 / ImGui) that accelerates asset creation for the engine.
The engine itself remains 100% free and open source. These tools are optional power-ups designed to streamline your workflow and support the project: each grants a lifetime license (one-time purchase, yours forever, free lifetime updates).
| Module |
Status |
| Sprite Compiler |
✅ Available — PNG to C headers (1bpp/2bpp/4bpp, grid selection) |
| Tilemap Editor |
✅ Available — visual multi-layer tilemaps with C++ export |
| Music Editor |
🔜 Coming soon — pattern-based tracker for the PR32 APU |
| SFX Editor |
🔜 Coming soon — sound effect synthesis |
👉 Get the Tool Suite · Detailed docs
💛 Support this project
The best way to support PixelRoot32 is getting the Tool Suite above — a lifetime license that funds the project.
If that's not for you, a tip is always welcome:
Quick Start
⚠️ Configuration Requirement
To compile PixelRoot32, you must configure your platformio.ini to use C++17 and disable exceptions:
build_unflags = -std=gnu++11
build_flags =
-std=gnu++17
-fno-exceptions
Prerequisites
- VS Code + PlatformIO
- ESP32 DevKit or SDL2 (for PC simulation)
📦 Installation (via PlatformIO)
To use PixelRoot32 in your own project, add the following to the lib_deps option of your platformio.ini:
lib_deps =
gperez88/PixelRoot32-Game-Engine@^1.16.0
PlatformIO will automatically download and install the library and its dependencies during the next build — including the shared PixelRoot32-APU synthesis core (also used by the PixelRoot32 Tool Suite).
Fast Setup
Clone this repository and open an example under examples/:
git clone https://github.com/PixelRoot32-Game-Engine/PixelRoot32-Game-Engine.git
cd PixelRoot32-Game-Engine/examples/sprites
Each folder (sprites, camera, animated_tilemap, physics, platformer, dialog, persistence, mono_oled, esp_now, esp_now_ping, apu_profiles) is a standalone PlatformIO project with its own platformio.ini. See the examples catalogue for what each one demonstrates and which opt-in capability it turns on. Complete games and larger use cases live in PixelRoot32-Demo-Projects.
Open that example folder in VS Code (File → Open Folder) and select the environment named in its platformio.ini (env:esp32dev, env:esp32cyd, env:esp32c3_node_up, env:esp32c3_node_a, env:native, and so on).
Build and Upload using PlatformIO.
📚 More information: See the Getting Started Guide.
🛠️ Best Practices
To ensure high performance on ESP32, PixelRoot32 enforces strict development patterns:
- Fixed-Point Math: Always use
Scalar instead of float. Use math::toScalar() for literals.
- Zero Allocation: Avoid
new/malloc during the game loop. Use Object Pooling and std::unique_ptr.
- Render Layers: Organize entities by
renderLayer (0=Bg, 1=Game, 2=UI) to optimize drawing order.
- Platform Memory: Use
PIXELROOT32_FLASH_ATTR and PIXELROOT32_READ_*_P macros for cross-platform Flash/RAM access.
- Centralized Logging: Use
log() from core/Log.h instead of Serial.print or printf.
📘 Essential Reading: Check the Style & Best Practices Guide for detailed rules on memory management, performance optimization, and coding style.
📚 Documentation
Online Resources
Local Reference
- Examples: Eleven minimal, single-idea capability examples (open a subfolder in PlatformIO).
- PixelRoot32-Demo-Projects: Complete games and per-topic demos. Anything larger than a single feature lives there, not in
examples/.
- Camera Example:
Camera2D following with smoothing and bounds, parallax layers, camera effects and a scripted CameraTween pan.
- Platformer Example:
KinematicActor, RigidActor and StaticActor in one screen, with one-way platforms and collision layers/masks — the Godot CharacterBody2D/RigidBody2D/StaticBody2D mapping.
- API Reference: Class reference and usage.
- Architecture: System design and layer hierarchy.
- Physics System: Flat Solver documentation.
- Audio Subsystem: Sound engine details.
- Persistence: Save/load module, its adapters and the record envelope.
- Contributing | Style Guide
🗺️ Roadmap
- 🔊 Audio Coprocessor Module: Optional dual-ESP32 architecture that offloads audio synthesis to a dedicated ESP32-C3 via SPI, improving game performance while remaining fully backward compatible.
- 💬 Dialog System, post-MVP: Remaining additions to the 1.11.0 dialog system that land when a game needs them: per-character text reveal with sound, and a localization text table.
👉 Full Roadmap: docs/roadmap.md — including completed features.
🕒 Changelog
1.16.0
A minor release: an opt-in microSD backend for persistence, plus build tooling. persistence::SdSlotStore (flag PIXELROOT32_ENABLE_SD_STORAGE, ESP32 only) keeps one FAT file per save slot and mounts from a plain-data SdConfig, so the adapter carries no board pin; a missing or unmountable card answers Unavailable and the game keeps running on defaults. examples/platformer puts KinematicActor, RigidActor and StaticActor in the scene they were designed for, examples/esp_now_dice moves to Demo-Projects, native builds resolve the host's SDL2 paths instead of committing per-OS flags, and native_test builds and instruments coverage on macOS.
Full changelog: CHANGELOG.md
🤝 Contribute
Contributions are welcome! Read our Contributing Guide to get started.
📄 License
PixelRoot32 is an open-source project licensed under the MIT License.
Based on ESP32-Game-Engine by nbourre.
See the LICENSE file for the full text.
⚠️ The PixelRoot32 Game Engine name and logo are subject to the trademark policy. See TRADEMARK.md.
👏 Credits
Developed by Gabriel Perez as a modular game engine for embedded systems.
Special thanks to nbourre for the original ESP32-Game-Engine.
Built with ❤️ for the retro-dev community.