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!