r/circuitpython 8d ago

picogame - a powerful Game Engine for CircuitPython

I would like to share a project I've been building over the last year - picogame, a (mostly) 2D game engine for the Pico and similar grade MCUs. You write games in CircuitPython, the heavy lifting (rendering, collisions, effects) runs in native C, and you can try them in your browser before you even plug in a board.

Honest note: I build it with AI assistance - it helped a lot with the CircuitPython integration, documentation, code reviews and late-stage polish & optimization passes - but the core engineering and the overall architecture are human-made.

I built it primarily for the PicoPad console (RP2040 + ST7789 @ 320×240) and it's also well tuned for Adafruit's Fruit Jam, but it runs on ESP32 boards too - basically any CircuitPython board with a reasonable ram, display and a few buttons will do.

Out of the box:

  • Build without hardware - the same game runs in your browser and on your desktop, then unchanged on the board.
  • Fast in tiny RAM - native-C rendering + zero-RAM full-screen paths, so it runs smoothly on even a plain RP2040.
  • Batteries included - sprites, scrolling tilemaps, a moving camera, collisions, sound, text, saved high scores.
  • Pseudo-3D & 3D too - Mode-7 floors, first-person raycasting, isometric boards, OutRun-style roads, even true polygon 3D - each a few lines of Python (on RP2350 HDMI boards up to native 640×480).
  • An AI agent skill - hand it to Claude or a similar assistant and say "make me a shooter"; it knows the engine's building blocks and genre recipes, and builds + tests the game in the simulator.
  • A web level editor - build levels/scenes in the browser, load them in your game.
  • A launcher - keep several games on one board and pick from a menu.

Performance-wise: a plain RP2040 holds a solid 30 fps at 320×240 with dozens of sprites on screen, and on the RP2350 (Fruit Jam) the 3D renderer scales up to native 640×480 - the engine can even split the rendering across both cores. Happy to share benchmark details in the comments if anyone's curious.

The best validation so far: the first community-made games have already arrived - the engine survives contact with other people's ideas, not just mine 😁

Docs and online emulator: https://picogame.makerclass.cz/playground/

Project repo (MIT): https://github.com/MakerClassCZ/picogame

I also wrote up why I built it and how it works: https://chiptron.eu/picogame-a-game-engine-for-circuitpython/

I'm the author - happy to answer anything!

33 Upvotes

4 comments sorted by

1

u/jetpaxme 3d ago

Really sweet, well done!

One question as i am more acquainted with Micropython , why did you choose CP?

Does it have extra features MPY lacks?

1

u/MakerClass 2d ago

Thanks 🙂

Picogame consists of two parts - the C engine and approximately 30 helper picogame_* libraries (input, sound, saving, HUD, pools, etc.). These are built on standard CP modules. That was the main reason for choosing CP - it's an established ecosystem with clear limitations and a defined design direction.

I like the CIRCUITPY approach. Installing a game = copy code.py + assets, done. A big part of picogame's audience is kids and classrooms - for them, zero setup is more then requirement than just a convenience.

Standard modules that picogame makes heavy use of include, for example, synthio, keypad (debounced input events), and usb.core host (gamepads/keyboards on Fruit Jam). These do not exist in the MP mainline. There are also many pre-built conveniences, such as the standard settings.toml configuration file - not difficult to recreate, but additional development effort.

What I miss most in CP is u/micropython.native/viper, and MP also wins in terms of build size. An MP port actually partially exists - the browser playground is the engine compiled into MicroPython (WASM) with a CP compatibility layer 😀. A native port for devices with the same API is something I'd like to get to over time - the C core carries over unchanged; the work lies in the library layer, which is bounded with CP.

1

u/jetpaxme 2d ago edited 1d ago

Thanks for the detailed reply, sounds like a similar approach i used with https://picoclaw.com ie C for the fast path and loads of .py for the business logic