rsnaker

Crates.iorsnaker
lib.rsrsnaker
version0.2.0
created_at2025-06-21 21:35:47.804028+00
updated_at2026-01-10 17:12:22.23568+00
descriptionA good old retro Snake in terminal UI
homepage
repositoryhttps://github.com/FromTheRags/rsnake
max_upload_size
id1721116
size1,765,235
0xTooManyLoot (FromTheRags)

documentation

https://docs.rs/rsnaker

README

crates.io Doc.rs GPLv3 License Last Commit Build Test Last doc Code lines

Snake Game using Ratatui

It is a terminal-based snake game using the Ratatui crate for rendering. Playing Snake Terminal Welcome Menu Terminal Output Menu Terminal Output Running

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 clap for command-line arguments & toml file.

TODO

  • Add timers to fruits ⏲️
  • Add some performance logs with tracing, for example
  • Enhance all table parameters based on the generic one
  • Channel for keyboard input
  • Add GIF management

💖 Support

  • 🥤If you like this game and want to contribute to more amazing features, consider giving me a coffee to support development: Support me on Ko-fi

Run Game options

  • To see run options, use: rsnake --help
  • E.g., rsnake -z 🐼 -b 🍥 or cargo run -- -z 🐼 -b 🍥 (if from source)
  • To save a set of parameters:
    • Use the in-game menu "edit", load a slot (with a number between 1 and 7), make your modifiation with arrows keys then save with 'x'
    • Create and alias for the CI option
  • Then load with --load option or using the in-game menu "edit".
    NB: You can download some of the Best Configurations and put it int he same folder as the executable

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/android:
    • cd "download path" && ./rsnake-x86_64-unknown-linux-gnu (or ./rsnake-x86_64-apple-darwin on macOS)
    • Or use the executable directly if you have it in your PATH.
  • See Run option below for more details.

Installation from source

✅ Prerequisites

Running

  • Clone this repository git clone https://github.com/FromTheRags/rsnake.git
  • Go to the directory cd rsnake
  • To run the game, either:cargo run or cargo 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 & RwLock for 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 test the 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 : codecov

Installation of Rust and tools for Linux

Make sure your system has curl, gcc and git installed:

sudo apt update
sudo apt install curl git gcc -y

Use the official installer rustup, or any alternative method on https://www.rust-lang.org/tools/install (by your own):

curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
  • Follow the prompts in the terminal.
  • After installation, run:
echo "source '$HOME/.cargo/env'" >> ~/.bashrc
source ~/.bashrc
  • Verify the installation:
rustc --version

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:

sudo apt install fonts-noto-color-emoji

For Arch Linux:

sudo pacman -S noto-fonts-emoji

For Fedora:

sudo dnf install google-noto-emoji-color-fonts

Optional: Configure Font Fallback (if emojis still do not render)

Create or edit the following file:

~/.config/fontconfig/fonts.conf

Add:

<?xml version="1.0"?>
<!DOCTYPE fontconfig SYSTEM "fonts.dtd">
<fontconfig>
    <alias>
        <family>sans-serif</family>
        <prefer>
            <family>Noto Color Emoji</family>
        </prefer>
    </alias>
</fontconfig>

Then refresh the font cache:

fc-cache -f -v

Test Your Setup

Run:

echo "Rust is awesome! 🦀🔥🚀"

You should see emojis rendered correctly in your terminal or text editors.

  • Then follow quick installation instructions

References

Commit count: 59

cargo fmt