A terminal-based snake game implemented in C++ with minimal dependencies, using thread for non-blocking input and
supporting both Windows and Unix systems.
- Cross-Platform: Supports both Windows and Unix (Linux, macOS).
- Real-Time Input: Non-blocking input handled via multi-threading.
- Colorful Gameplay: Uses ANSI escape codes for colored snake body and fruit.
- Score Tracking: Tracks and displays the score in real-time.
- Arrow keys to control the snake's direction:
- Up, Down, Left, Right for respective directions.
- The snake grows when it eats the fruit (
*), and the game ends if the snake hits the screen edge or its own body. - The goal is to achieve the highest score possible.
-
Compile with:
g++ snake_game.cpp -o snake_game -pthread
-
Run with:
./snake_game
- The game relies on ANSI escape codes for colored output, so it's best played on a compatible terminal.