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.
TODO
- Add a save score (local db) with a pseudo got from cmdline
- Add preset for saved configuration
- Add timers to fruits ⏲️
- Add some performance log with tracing, for example
- Enhance all table parameters based on generic one
- Internal code: Provide a macro example for trait implementation widget and this error use.
💖 Support
- 🥤If you like this game and want to contribute to more amazing features, consider giving me a coffee to support
development:
Run Game options
- To see run options, use:
rsnake --help - E.g.,
rsnake -z 🐼 -b 🍥orcargo run -- -z 🐼 -b 🍥(if from source) - To save a set of commands, create and alias or use
--saveto generate to a snake_config.toml file near the executable. - Then load with
--loadoption. Shipped one
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, if need install the Noto Emoji font : 👉 Emoji font support for instructions.
- Some screen display can flicker at 60 FPS in the terminal, use a decent display or an external monitor.
Running
- Download the latest release from the releases page according to your OS.
- Run the executable using the terminal or double click on the file if your OS support 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/android:
cd "download path" && ./rsnake-x86_64-unknown-linux-gnu(or./rsnake-x86_64-apple-darwinon macOS)- Or use the executable directly if you have it in your PATH.
- See Run option below for more details.
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 👉 Installation Rust and tools for Linux for instructions
- On Android use a linux emulator and follow same instruction as linux, tested with:
- Android using Ubuntu,
- Termux
For easier use, END key works as ENTER and HOME as a pause key.
Running
- 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
- Uses
Arc&RwLockfor synchronization. - Spawns separate threads for input handling, rendering (60Hz), 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:rustup component add llvm-tools-preview cargo install cargo-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 :
Installation Rust and tools for Linux
Make sure your system has curl, gcc and git installed:
Use the official installer rustup, or any alternative method on https://www.rust-lang.org/tools/install (by your own):
|
- Follow the prompts in the terminal.
- After installation, run:
- Verify the installation:
Enable Emoji Font Support
To properly display emoji characters in your terminal and system fonts, install an emoji-compatible font.
For Ubuntu/Debian-based distros:
For Arch Linux:
For Fedora:
Optional: Configure Font Fallback (if emojis still do not render)
Create or edit the following file:
Add:
sans-serif
Noto Color Emoji
Then refresh the font cache:
Test Your Setup
Run:
You should see emojis rendered correctly in your terminal or text editors.
- Then follow quick installation instructions
References
-
Clippy lints: https://github.com/rust-lang/rust-clippy/
-
Ratatui tutorial: https://ratatui.rs/tutorials/hello-world/
-
Git over-bloated: https://rtyley.github.io/bfg-repo-cleaner/
-
Asciinema & SVG: https://docs.asciinema.org https://github.com/marionebl/svg-term-cli With asciinema rec demo.cast && svg-term --in demo2.cast --out demo5.svg --term terminal --profile seti --width 200 --height 18