A nostalgic Snake game that runs in your terminal, featuring a start menu, colored walls, sounds, and a compact HUD. Built with Rust + crossterm.
- Start menu with speed options: Slow, Medium, Fast, Very Fast
- Choose terminal playfield size: Small, Medium, Large, Extra Large, or autoâdetect current size
- Yellow "wall-like" borders rendered with star characters
- Live HUD: score, speed label, music status
- Music/Sound (MP3): background music, eat, and game over sounds
- Fun emoji food (đ)
- Crossâplatform: Windows, macOS, Linux (UTFâ8, colors, and raw mode supported)
Prerequisites:
- Rust and Cargo (https://www.rust-lang.org/tools/install)
Build:
cargo build --release
Run:
cargo run
Or run the built binary:
./target/release/snake_game_cli
- Movement: Arrow Keys or WASD
- Speed selection: Use Up/Down on the start menu and press Enter
- Inâgame shortcuts:
- R: Restart
- E: Toggle emoji mode
- M or 0: Toggle music
- Esc: Open the gameâover menu (Exit/Retry)
HUD shows: SNAKE | Score | Speed | Music [M/0] | [WASD/Arrows] Move | [Esc] Quit | [R] Restart
At startup you can choose:
- Small (40x20)
- Medium (60x25)
- Large (80x30)
- Extra Large (100x35)
- Autoâdetect current terminal size
Notes:
- Recommended minimum: ~15x8
- The game clamps the chosen size to the actual terminal size to avoid outâofâbounds rendering.
Expected files at the project root:
- arcade.mp3 (background)
- eat.mp3 (eat/collect)
- gameover.mp3 (game over)
If a file is missing, the game will warn and may fall back to a terminal beep.
Platform notes:
- Windows: Code page is switched to UTFâ8 (chcp 65001) at launch for proper emoji and colors.
- Linux/macOS: MP3 playback requires system audio backends (e.g., PulseAudio/ALSA on Linux, CoreAudio on macOS). If audio fails, check your system audio setup.
- Color/style bleed: ResetColor is used at frame/menu boundaries; if your terminal theme is very dark, HUD contrast may vary.
- Very small terminals: Elements can overlap. Choose a larger size.
- Emoji not visible: Your terminal font might lack emoji support. Try another font/terminal.
- Performance: On very small/old machines, Very Fast mode may increase CPU usage. Medium is a good default.
- No MP3 playback: Ensure the MP3 files exist at the project root and your system audio is working.
Rendering uses crossterm. The main loop is in src/main.rs and src/game.rs; drawing logic is in src/render.rs.
You can easily tweak speed presets, menu visuals, wall character/color, and HUD text. Before sending patches, consider running cargo fmt
and optionally cargo clippy
.
Local run:
cargo run
This project is licensed under the MIT License (unless stated otherwise). Use according to the license terms.
- Thanks to the crossterm project and the Rust community.