A classic Snake Game built using HTML, CSS, and JavaScript, featuring smooth movement, sound effects, and score tracking.
- Real-time snake movement using keyboard controls
- 🍎 Food spawning at random positions
- 🔊 Sound effects for movement, eating, and game over
- 🧠 Collision detection (self + walls)
- 🏆 High score saved using browser local storage
- ⚡ Adjustable game speed
Use the arrow keys to control the snake:
- ⬆️ Up Arrow → Move Up
- ⬇️ Down Arrow → Move Down
- ⬅️ Left Arrow → Move Left
- ➡️ Right Arrow → Move Right
- Clone the repository:
git clone https://github.com/your-username/snake-game.git-
Open the project folder
-
Run the game:
- Open
index.htmlin your browser
Snake Game/
│── index.html
│── Snake.js
│── Snake.css
│── Audio/
│ ├── Bite.wav
│ ├── Die.wav
│ ├── Move.wav
│ └── Music.wav
-
The game loop runs using
requestAnimationFrame -
The snake position is stored as an array of coordinates
-
Each frame:
- Movement updates based on user input
- Collision detection is checked
- Food consumption increases score and length
-
High score is stored in localStorage
- Snake grows when it eats food
- Game resets on collision
- Speed controls how fast the game updates
- Food appears randomly within the grid
- HTML5
- CSS3 (Grid-based layout)
- JavaScript (Game logic & DOM manipulation)
⭐ If you like this project, consider starring the repo!