1,021 B
1,021 B
Tetris (C + SDL3)
A small Tetris clone written in C using SDL3 for rendering/input and SDL3_ttf for text.
Build
Requirements:
- CMake (3.7+)
- SDL3
- A C compiler (gcc/clang)
Configure and build:
cmake -S . -B build
cmake --build build
Run:
./build/tetris
Controls
- Move left:
LeftorA - Move right:
RightorD - Rotate:
UporW - Soft drop:
DownorS - Quit:
QorEsc
Gameplay Notes
- The board is
10 x 16(include/grid.h). - Shapes are stored as an origin block plus 3 relative offsets (
src/shape.c). - Rotation uses a 90-degree transform around the origin:
(x, y) -> (-y, x)(src/game.c). - Collision checks allow negative
yvalues so pieces can spawn/rotate partly above the visible top (src/grid.c). - Line clear logic re-checks the same row index after a clear, because rows above are shifted down (
src/grid.c).
Debug Logging
Debug logs are compiled in when APP_DEBUG is enabled (for example in Debug builds through CMake).