A simple command-line Tetris clone with classic features:
- 7-Bag Randomizer (modern Tetris style)
- Piece Hold (
Ckey) - Next Piece Preview (3 pieces)
- Soft Drop (Down arrow), Hard Drop (Space)
- Scoring & Levels (increasing speed)
- A Rust toolchain (stable, 2021 edition) —
cargoandrustc. - An interactive terminal (TTY). The game enables raw mode, so it cannot run headless or in CI.
cargo build # debug build
cargo build --release # optimized build (binary in target/release/tetris-cli)cargo run # build and play
./target/release/tetris-cli # run a release binary directlyNote:
cargo runneeds a real interactive terminal because it switches the terminal into raw mode. It won't work when piped, redirected, or run in CI.
cargo test # run all unit + integration tests
cargo test test_clear_tetris_and_non_adjacent # run a single test by nameAll game logic lives in the tetris_cli library, so tests run fully headless —
no terminal required.
These mirror the CI gate (.github/workflows/main.yml); run them before pushing:
cargo fmt --all --check # verify formatting
cargo clippy --all-targets --all-features -- -D warnings # lint (warnings fail)
cargo llvm-cov --summary-only # coverage (cargo install cargo-llvm-cov)The controls are also listed live in-game, in a panel below the score.
- Left / Right Arrows: Move the falling piece left or right
- Down Arrow: Soft drop (speeds up piece descent)
- Up Arrow: Rotate the piece clockwise
Z: Rotate the piece counterclockwiseSpace: Hard drop (instantly drops the piece to the bottom)C: Hold the current piece (swap with the previously held piece)Escor Ctrl + C: Quit the game
- Single Line Clear: 40 points × (level + 1)
- Double: 100 points × (level + 1)
- Triple: 300 points × (level + 1)
- Tetris (4 lines): 1200 points × (level + 1)
- Level increases every 10 lines cleared.
- As the level goes up, pieces drop faster (gravity interval decreases).
Enjoy the classic Tetris experience right in your terminal!