A classic Snake Game implemented in C++ — works on Windows & Linux & Mac!
- Features
- Gameplay Mechanics
- Installation & Run
- Game Controls
- Difficulty Levels
- Technical Details
- Future Enhancements
- Contribution
- Contributors
- 🔮 Cross-Platform Compatibility (Windows & Linux & Mac)
- 🛠️ Adjustable Difficulty Levels (Easy, Medium, Hard)
- ⭐ Smooth Gameplay with responsive controls
- ⚙️ Optimized Code using Object-Oriented Programming (OOP) principles
- Control the snake using W, A, S, D keys.
- Eat the food (🍓) to grow your tail and increase your score!
- Avoid colliding with the walls or yourself.
- Game Over when you hit a wall or your own body.
- Press 'Esc' to quit the game anytime.
- ** Press 'p'** to pause the game.
git clone https://github.com/yourusername/SnakeGame.git
cd SnakeGame
g++ snake_game.cpp -o snake_game.exe -static-libstdc++ -static-libgcc
.\snake_game.exe
g++ snake_game.cpp -o snake_game
./snake_game
Key | Action |
---|---|
W | Move Up |
A | Move Left |
S | Move Down |
D | Move Right |
P | Pause Game |
ESC | Quit Game |
Upon starting, choose a difficulty level:
- 1 - Easy (🏆 60ms delay)
- 2 - Medium (🌟 35ms delay)
- 3 - Hard (🥇 15ms delay)
- Uses vector for snake body storage.
- Platform-Specific Input Handling:
- Windows: Uses
_kbhit()
and_getch()
. - Linux: Uses
termios
andselect()
.
- Windows: Uses
- Randomized food placement to avoid spawning inside the snake.
- 🌈 Custom themes & colors
- 🌟 Score leaderboard
- 🧠 Obstacles & Power-ups
- ⭐ Multi-level game modes
- Fork the repo.
- Create a new branch (
feature-xyz
). - Commit changes (
git commit -m "Added xyz feature"
). - Push (
git push origin feature-xyz
). - Open a Pull Request!
Give this project a ⭐ if you like it!
Enjoy the game! 🚀