Sxtetris

August 26, 2025 ยท View on GitHub

A terminal Tetris game written in Rust, built with ratatui and tokio.

https://github.com/shixinhuang99/sxtetris/assets/31186725/1eb95c10-e57e-4239-8142-95800e1afca8

Features

  • Classic Tetris gameplay in your terminal
  • Smooth animations and responsive controls
  • Background music and sound effects
  • High score tracking
  • Cross-platform compatibility

Installation

Homebrew

brew tap shixinhuang99/brew
brew install sxtetris

Cargo

cargo install sxtetris --locked

AUR (Arch Linux)

You can install sxtetris from the AUR by using an AUR helper:

paru -S sxtetris

Binary Releases

Download pre-built binaries from the latest releases.

System Requirements

  1. Terminal Size: Suggested minimum terminal size: 105x45
  2. Color Support: Terminal must support 24-bit color (true color)
  3. Recommended Terminals:
    • macOS: iTerm2
    • Linux: GNOME Terminal
    • Windows: Windows Terminal

Usage

sxtetris

To see the save file location:

sxtetris --show-save-path

Audio Sources

All audio files are located in the src/global/assets directory. Files from freesound have been trimmed for optimal gameplay experience.

FileAuthorSource
bg_music.mp3Stable AudioStable Audio
game_over.wavthemusicalnomadFreeSound
lock.wavMellauFreeSound
menu.wavChristopherderpFreeSound
move.wavaphom000FreeSound
clear.mp3B_LamerichsFreeSound

Troubleshooting

Linux ALSA Error

If you encounter the following error when using cargo install:

The system library `alsa` required by crate `alsa-sys` was not found.
The file `alsa.pc` needs to be installed and the PKG_CONFIG_PATH environment variable must contain its parent directory.
The PKG_CONFIG_PATH environment variable is not set.

HINT: if you have installed the library, try setting PKG_CONFIG_PATH to the directory containing `alsa.pc`.

Run these commands and try installing again:

sudo apt-get update
sudo apt-get install libasound2-dev
export PKG_CONFIG_PATH=$PKG_CONFIG_PATH:/usr/lib/pkgconfig:/usr/lib/x86_64-linux-gnu/pkgconfig

Disclaimer

This project is an open-source implementation of Tetris designed to run in the terminal. Tetris is a registered trademark, and all rights belong to its respective owners. This project is intended solely for educational and research purposes and should not be used for commercial purposes.

By using this project, you agree to use it exclusively for non-commercial educational and research purposes. The developer assumes no responsibility for any infringement of intellectual property rights.