A classic Snake game implementation in Rust using the Crossterm library for terminal manipulation.
This is a simple, terminal-based Snake game where you control a snake that grows longer as it eats food. The game ends when the snake hits the wall or itself.
- Rust and Cargo (https://www.rust-lang.org/tools/install)
- Dependencies:
- crossterm (for terminal manipulation)
- rand (for random food placement)
- Clone this repository or create a new Rust project
- Add the following dependencies to your
Cargo.toml
:
[dependencies]
crossterm = "0.26.1"
rand = "0.8.5"
- Copy the source code into
src/main.rs
- Build and run the game with
cargo run
- Use arrow keys (↑, ↓, ←, →) to navigate the snake
- Eat food (●) to increase your score and make the snake grow
- Avoid hitting walls and the snake's own body
- Press 'q' to quit the game
- ↑ (Up Arrow): Change direction to upward
- ↓ (Down Arrow): Change direction to downward
- ← (Left Arrow): Change direction to left
- → (Right Arrow): Change direction to right
- q: Quit the game
- ■: Snake head
- □: Snake body
- ●: Food
- █: Walls/Border
Created and maintained by "PocketJack (Rez Khaleghi)"
- GitHub: https://github.com/rezkhaleghi
- Email: rezaxkhaleghi@gmail.com
If you enjoy this app and would like to support my work:
- Patreon : https://patreon.com/PocketJack Your support helps me continue developing free and open-source stuff.
This project is available under the MIT License.
- Built with Rust and Crossterm
- Inspired by the classic Snake game on nokia
Contributions are welcome! Feel free to submit a Pull Request.