A modern, responsive Snake Game built using HTML5 Canvas, Vanilla JavaScript (ES Modules), HTML, and CSS. The project features a retro-inspired UI, smooth gameplay, increasing difficulty, mobile controls, sound effects, and a modular architecture for maintainability.
Live Demo: https://vinniit-23.github.io/Snake-Game/
GitHub Repository: https://github.com/vinniit-23/Snake-Game
Add screenshots or GIFs of your game here.
| Desktop | Mobile |
|---|---|
![]() |
![]() |
- 🎮 Classic Snake gameplay
- ⚡ Increasing speed as you level up
- 🍎 Random food generation
- 🌈 Random food colors
- 📈 Score counter
- 🏆 High Score (stored using Local Storage)
- 🎯 Level system
- 🔊 Sound effects
- 📱 Mobile-friendly D-Pad controls
- ⏸️ Pause & Resume support
- 🔄 Restart game anytime
- 💀 Game Over screen
- 🎨 Retro-inspired UI
- 🧩 Modular JavaScript architecture using ES Modules
- HTML5
- CSS3
- JavaScript (ES6+)
- HTML5 Canvas API
Snake-Game/
│
├── index.html
├── style.css
│
├── js/
│ ├── game.js
│ ├── snake.js
│ ├── food.js
│ ├── collision.js
│ ├── constant.js
│ ├── rerender.js
│ ├── ui.js
│ ├── main.js
│ │
│ └── input/
│ └── direction.js
| └── dpad.js
| └── input.js
| └── swipe.js
│
├── Audios/
│
├── Images/
│
└── README.md
git clone https://github.com/vinniit-23/Snake-Game.gitcd Snake-GameSimply open index.html in your browser.
Or use VS Code Live Server.
| Key | Action |
|---|---|
| ⬆️ | Move Up |
| ⬇️ | Move Down |
| ⬅️ | Move Left |
| ➡️ | Move Right |
| Start Button | Start Game |
| Pause Button | Pause Game |
| Resume Button | Resume Game |
| Restart Button | Restart Game |
Use the on-screen D-Pad or swipe to control the snake .
- Eat food to increase your score.
- Every few foods:
- Level increases
- Snake speed increases
- Avoid:
- Hitting the walls
- Hitting yourself
- Beat your High Score!
While building this project I learned:
- HTML5 Canvas API
- Game loop architecture
- Collision detection
- Object-oriented game logic
- JavaScript ES Modules
- State management
- Event handling
- Local Storage
- Code modularization
- Responsive game UI
- Mobile controls
- Audio integration
Contributions are welcome!
If you'd like to improve the project:
- Fork the repository
- Create a new branch
git checkout -b feature-name- Commit your changes
git commit -m "Add feature"- Push
git push origin feature-name- Open a Pull Request
If you discover any bugs, please open an issue describing the problem.
If you enjoyed this project, consider giving it a ⭐ on GitHub!
It really helps and motivates me to build more projects.
This project is licensed under the MIT License.
Vinit Pandey
Made with ❤️ using JavaScript by Vinit🤍.

