I made for this for Coding Challenges's Tetris challenge.
I wanted to try hot reloading in C through recompiling & reloading the core game logic as a shared library. Being a big Zig fan, I decided to use Zig's build system to enable doing this in debug mode, but compile it all statically in release modes. If you hit the 'R' key in-game in a debug build, the game will reload but the state will be retained.
My final goal was getting this to run on the Steam Deck, which in the end worked wonderfully (see tweet)!
- Working Tetris game
- Supports Linux & Macos
- Keyboard & Mouse + Controller Support
- Music & Sound Effects
- Windowed & Fullscreen Modes
- You'll need Zig, which you can get here. I'm currently using the latest nightly:
0.12.0-dev.2139+e025ad7b4
. This includes a C compiler withzig cc
! - You will also need the Raylib development library dependencies. See the Working on {YOUR OS} sections of Raylib's wiki.
Now you're ready to go!
To run a debug build, run:
zig build run
To run a release build, run:
zig build -Doptimize=ReleaseSafe run
You can run in fullscreen mode with the --fullscreen
flag.
zig build run -- --fullscreen
This image was made for the purposes of a colorful screenshot, ignore all the gaps :)