Skip to content

togisoft/snake_game_cli

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

SNAKE ARCADE (CLI)

A nostalgic Snake game that runs in your terminal, featuring a start menu, colored walls, sounds, and a compact HUD. Built with Rust + crossterm.

đŸŽ„ Demo Video

Watch on YouTube

Snake Game Screenshot

Features

  • 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)

Install

Prerequisites:

Build:

cargo build --release

Run:

cargo run

Or run the built binary:

./target/release/snake_game_cli

Gameplay & Controls

  • 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

Terminal Size

At startup you can choose:

  1. Small (40x20)
  2. Medium (60x25)
  3. Large (80x30)
  4. Extra Large (100x35)
  5. 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.

Audio / Music

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.

Tips & Troubleshooting

  • 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.

Development

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

License

This project is licensed under the MIT License (unless stated otherwise). Use according to the license terms.

Acknowledgements

  • Thanks to the crossterm project and the Rust community.

About

🐍 A simple Snake Game written in Rust, running in the terminal.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages