1
0
Fork 0
tetris-c/README.md
2026-05-10 00:20:28 +02:00

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: Left or A
  • Move right: Right or D
  • Rotate: Up or W
  • Soft drop: Down or S
  • Quit: Q or Esc

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 y values 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).