https://github.com/candrewlee14/tetris-raylib
Tetris clone built with Raylib
https://github.com/candrewlee14/tetris-raylib
c raylib tetris zig
Last synced: 4 months ago
JSON representation
Tetris clone built with Raylib
- Host: GitHub
- URL: https://github.com/candrewlee14/tetris-raylib
- Owner: candrewlee14
- License: mit
- Created: 2024-01-11T22:33:10.000Z (over 2 years ago)
- Default Branch: main
- Last Pushed: 2024-12-19T19:45:12.000Z (over 1 year ago)
- Last Synced: 2025-09-05T12:48:14.830Z (10 months ago)
- Topics: c, raylib, tetris, zig
- Language: C
- Homepage:
- Size: 6.53 MB
- Stars: 3
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Tetris-Raylib
I made for this for [Coding Challenges](https://codingchallenges.fyi/)'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](https://x.com/c_andrew_lee/status/1748146829504692384?s=20))!
## Features
- Working Tetris game
- Supports Linux & Macos
- Keyboard & Mouse + Controller Support
- Music & Sound Effects
- Windowed & Fullscreen Modes
## Setup
- You'll need Zig, which you can get [here](https://ziglang.org/download/). I'm currently using the latest nightly: `0.12.0-dev.2139+e025ad7b4`. This includes a C compiler with `zig cc`!
- You will also need the Raylib development library dependencies. See the _Working on {YOUR OS}_ sections of Raylib's [wiki](https://github.com/raysan5/raylib/wiki).
Now you're ready to go!
To run a debug build, run:
```bash
zig build run
```
To run a release build, run:
```bash
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 :)