Thumby game dev
I am pretty bad at sticking to plans, but ... whatever. Here's a little game in the making:
The game controls are as follows:
- Arrow/WASD keys to move
- Q/E shoulder buttons: change scene index (E = next scene)
- I/J: A and B buttons
- M: Menu button
It's not really a game yet. It is targetting the Thumby Color device, which has the following specs:
- 128x128 screen
- Raspberry Pico 2 (RP2350)
- 520KB RAM
- 16MB flash
- Dual Arm Cortex-M33
The build system I came up with is also a bit of a new ground for me:
- A batch file compiles a build.c file
- The build.c file is compiled and executed with arguments
- The build.c file reads the assets directory and converts images into C arrays - because there's no file system (that I am aware of)
- It then writes the C arrays into a header file
- If it is a bitmap font file, it loads the font using the raylib font loader and produces additional font data
- The build.c file is then compiling either the raylib or web runtime
I am using raylib for the desktop testing, but the game itself is runtime agnostic: An init and update function receive a RuntimeContext struct that contains the screen buffer and input state. The game is then responsible for rendering and updating the game state - which means software 2d rendering. So the raylib runtime takes the screen data and converts it into a texture that is then rendered on the screen.
The raylib runtime is also allowing recompiling the code while running, allowing fast iteration on the code.
The runtime is also running on the Thumby Color device:
And now it's also running in the browser. The port was quite straight forward:
- Compile the game code with Emscripten
- Provide a few helper functions to manage the runtime context struct
- Create a simple main loop that calls the game update and render functions
The result is a minimal self contained emscripten game. Since the assets are contained in the binary, the emscripten compilation doesn't need to include an asset folder.
So far I really like the system I've created. The thumby runtime is sadly not yet integrated in the build system: I have an external project to build the thumby runtime. It would be great to include the build steps in the build.c file as well, but I haven't found the time and energy yet to do so.