A simple classic Snake game built using C++ for the Windows console. The snake moves using keyboard input, eats fruit to grow longer, and the game ends when it hits a wall or itself.
| Key | Action |
|---|---|
| W | Move Up |
| A | Move Left |
| S | Move Down |
| D | Move Right |
| X | Exit Game |
- Console-based UI
- Snake grows when eating fruit
- Score tracking
- Wall collision detection
- Self-collision detection
- Adjustable game speed
-
Windows OS
-
C++ Compiler (g++, MSVC, etc.)
-
Headers used:
<iostream><conio.h><cstdlib><ctime><windows.h>
g++ snake_game.cpp -o snake_gamesnake_gameIn main() function:
Sleep(300); // Increase for slower game| Value | Speed |
|---|---|
| 100 | Fast |
| 200 | Normal |
| 300 | Slow |
| 400 | Very Slow |
snake-game/
โโโ snake_game.cpp
โโโ .gitignore
โโโ README.md
Built as a learning project to practice:
- C++
- Game logic
- Keyboard input
- Git & GitHub usage
Enjoy the game! ๐