Skip to content

vinniit-23/Snake-Game

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

🐍 Snake Game

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.


🎮 Demo

Live Demo: https://vinniit-23.github.io/Snake-Game/

GitHub Repository: https://github.com/vinniit-23/Snake-Game


📸 Preview

Add screenshots or GIFs of your game here.

Desktop Mobile
Desktop Screenshot Mobile Screenshot

✨ Features

  • 🎮 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

🛠️ Tech Stack

  • HTML5
  • CSS3
  • JavaScript (ES6+)
  • HTML5 Canvas API

📂 Project Structure

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

🚀 Getting Started

Clone the repository

git clone  https://github.com/vinniit-23/Snake-Game.git

Go to the project

cd Snake-Game

Run the project

Simply open index.html in your browser.

Or use VS Code Live Server.


🎯 Controls

Desktop

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

Mobile

Use the on-screen D-Pad or swipe to control the snake .


🎲 Gameplay

  • Eat food to increase your score.
  • Every few foods:
    • Level increases
    • Snake speed increases
  • Avoid:
    • Hitting the walls
    • Hitting yourself
  • Beat your High Score!

🧠 What I Learned

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

🤝 Contributing

Contributions are welcome!

If you'd like to improve the project:

  1. Fork the repository
  2. Create a new branch
git checkout -b feature-name
  1. Commit your changes
git commit -m "Add feature"
  1. Push
git push origin feature-name
  1. Open a Pull Request

🐛 Found a Bug?

If you discover any bugs, please open an issue describing the problem.


⭐ Support

If you enjoyed this project, consider giving it a ⭐ on GitHub!

It really helps and motivates me to build more projects.


📄 License

This project is licensed under the MIT License.


👨‍💻 Author

Vinit Pandey


Made with ❤️ using JavaScript by Vinit🤍.

About

A Snake game with html css and javascript

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

No releases published

Packages

 
 
 

Contributors