Snake Game using Ratatui
It is a terminal-based snake game using the Ratatui crate for rendering.

Features
- Terminal UI: Uses Ratatui for rendering a grid-based game.
- Game Logic: Manages snake movement, collisions, and scoring.
- Multithreading: Uses multiple threads for input handling, rendering at 60 FPS, and game logic execution.
- Emoji-based graphics: Supports rendering the snake using emojis instead of ASCII.
- Configurable parameters: With
clapfor command-line arguments & toml file.
Installation from release
✅ Prerequisites
- 💻 Use a terminal that supports emoji
- On Windows, the new Microsoft terminal shipped with w11 (and compatible w10) supports emoji out of the box among other improvements.
- On Linux / Android, you could need to install the Noto Emoji font: 👉 Emoji font support for instructions.
- Some screen displays can flicker at 60 FPS in the terminal, use a decent display or an external monitor.
Running
- Download the latest release from the release page according to your OS.
- Run the executable using the terminal or double-click on the file if your OS supports it.
- For windows:
- Search for "Terminal" in the search menu to launch it and set as default (to be able to run the snake by double-clicking the .exe) or run rsnake from the terminal with:
cd "download path"then.\rsnake-x86_64-pc-windows-msvc.exe
- For Linux/macOS:
cd "download path" && ./rsnake-x86_64-unknown-linux-gnu(or./rsnake-x86_64-apple-darwinon macOS)
- For android:
- Use a linux emulator, tested with:
- Android using Ubuntu (I have committed a PR to be integrated by default, see fork)
- Termux
For easier use, END key works as ENTER, "-" as a pause key, HOME for Menu, Tab to quit.
- Take the ARM binaries from the release page (static build for broader compatibility)
- Use a linux emulator, tested with:
In case pre-build binaries are not enough, you can build from source Installation from source
Run Game options
- To see run options, use:
rsnake --help - E.g.,
rsnake -z 🐼 -b 🍥orcargo run -- -z 🐼 -b 🍥(if from source)
TOML Presets
- To save a set of parameters:
- Use the in-game menu "edit", load a slot (with a number between 1 and 7), make your modification with arrows keys, then save with 'x'
- Create and alias for the CI option
- Then load with
--loadoption or using the in-game menu "edit".
NB: You can download some of the Best Configurations and put it in the same folder as the executable
Installation from source
✅ Prerequisites
- 🦀 Have Rust and compilation tools installed
If you don't have Rust yet:- On Windows, Install Rust using the official .exe installer https://www.rust-lang.org/tools/install (as it works Out-Of-The-Box on Windows)
- On Linux/ Android with linux emulator 👉 Installation Rust and tools for Linux for instructions
Running from source
Short path
- Using cargo only:
cargo install --locked rsnaker --force - To run the game execute:
rsnake, if not found, the binary is in~/.cargo/bin/rsnake
Long path
- Clone this repository
git clone https://github.com/FromTheRags/rsnake.git - Go to the directory
cd rsnake - To run the game, either:
cargo runorcargo run --manifest-path rsnake/Cargo.toml(if in another directory) - To install the game as a command:
cargo install --path .
And then run the game with:rsnake - See Run option below for more details.
Architecture
Full details are available in architecture.md.
-
Logging Configuration
The logging subsystem is configured from a dedicated TOML file (snake_log_config.toml), separate from the game
options file. It is read only once at startup, and is deserialization-only (the game never writes back to it).
If the file is missing or invalid, sensible defaults are used.
# snake_log_config.toml
= "off" # off, error, warn, info, debug, trace
= "snake.log" # output log file (current directory)
= "[hour]:[minute]:[second].[subsecond digits:6]" # `time` crate format description
= false # ANSI colors in the log file
= false # include the module path (target)
= true # include thread names
= false # include thread ids
= true # include source line numbers
= true # include source file names
= true # include the log level
The CLI flag --log-level (if explicitly set, i.e., not off) overrides the level coming from the TOML file via the
hot-reload handle, as well as log option overrides if set in game-preset file/menu.
- Uses
Arc&RwLockfor synchronization. - Spawns separate threads for input handling, rendering (60 Hz), and game logic execution.
Documentation generation
cargo doc --document-private-items --no-deps --open
Tests
- As usual run them with
cargo testthe project is set up with a lib containing all the code, and a main.rs just calling it - As this is a widespread pattern providing full compliance with the Rust test ecosystem, allowing doc comment to be automatically tested, for example.
- To have a coverage report, install
llvm-cov: - And run
cargo llvm-cov --open - A great coverage is not a goal for this project (tests are only there to showcase tests in rust),
- For reference, the current coverage is :
References
- Clippy lints: https://github.com/rust-lang/rust-clippy/
- Ratatui tutorial: https://ratatui.rs/tutorials/hello-ratatui/
- Example: https://ratatui.rs/examples/widgets/canvas/
- Git over-bloated: https://rtyley.github.io/bfg-repo-cleaner/
- Gif: OBS studio full screen with filter to terminal view and
ffmpeg
with:
ffmpeg -ss 00:00:01 -to 00:00:20 -i input.mp4 -vf "fps=10,scale=1400:-1:flags=lanczos" -loop 0 output.gif
(well better than asciinema)