███████╗███╗ ██╗ █████╗ ██╗ ██╗███████╗
██╔════╝████╗ ██║██╔══██╗██║ ██╔╝██╔════╝
███████╗██╔██╗ ██║███████║█████╔╝ █████╗
╚════██║██║╚██╗██║██╔══██║██╔═██╗ ██╔══╝
███████║██║ ╚████║██║ ██║██║ ██╗███████╗
╚══════╝╚═╝ ╚═══╝╚═╝ ╚═╝╚═╝ ╚═╝╚══════╝
██████╗ █████╗ ███╗ ███╗███████╗
██╔════╝ ██╔══██╗████╗ ████║██╔════╝
██║ ███╗███████║██╔████╔██║█████╗
██║ ██║██╔══██║██║╚██╔╝██║██╔══╝
╚██████╔╝██║ ██║██║ ╚═╝ ██║███████╗
╚═════╝ ╚═╝ ╚═╝╚═╝ ╚═╝╚══════╝
⚡ A classic arcade Snake Game built in terminal using arrays, loops, collision detection, and real-time keyboard controls.
This project is a console-based implementation of the classic Snake Arcade Game developed in C++ using procedural programming fundamentals.
The game executes entirely inside the terminal and demonstrates:
- ⚡ Real-time keyboard event handling
- 🎮 Frame-based rendering loop
- 🐍 Snake body movement using arrays
- 🍎 Random food generation
- 💥 Collision detection (wall + self)
- 📊 Score tracking and HUD display
- 🔁 Restart and exit controls
No external libraries — pure system-level programming.
| Feature | Description |
|---|---|
| 🎯 Real-Time Input | Uses _kbhit() and _getch() for non-blocking keyboard capture |
| 🐍 Dynamic Snake Growth | Snake length increases after consuming food |
| 🍎 Random Food Logic | Food spawns randomly within board boundaries |
| 💥 Collision Engine | Detects self-hit and wall-hit conditions |
| 📊 HUD Display | Live score, length, controls, objective shown on top |
| 🔁 Restart Option | Allows replay after Game Over |
| 🎨 Console Styling | Colored borders and terminal UI enhancement |
int snakeX[MAX_LENGTH], snakeY[MAX_LENGTH];while (!gameOver)
{
handleInput();
update();
draw();
Sleep(SPEED_MS);
}- Boundary checks
- Self overlap detection
- Food consumption → growth
git clone https://github.com/arya-dev2005/Snake-Game.gitcd Snake-Gameg++ snake_game.cpp -o snake_gamesnake_game.exe| Key | Action |
|---|---|
| W / ↑ | Move Up |
| S / ↓ | Move Down |
| A / ← | Move Left |
| D / → | Move Right |
| Q | Quit |
| R | Restart |
Snake-Game/
│── snake_game.cpp
│── README.md
│── snake_preview.png
│── .github/
│ └── workflows/
│ └── snake.yml
- Efficient array-based snake movement
- Non-blocking input handling
- Flicker-free rendering using cursor control
- Clean procedural design architecture
- 🎨 Themes / color modes
- 🔊 Sound effects
- 🧠 AI Snake mode
- 🌐 Cross-platform support
- 🧩 OOP-based refactor
Pull requests are welcome. For major changes, please open an issue first.
This project is open-source under the MIT License.