A simple and interactive Snake Game built using HTML, CSS, and Vanilla JavaScript. The project demonstrates DOM manipulation, keyboard event handling, game loops, collision detection, and dynamic rendering.
- 🐍 Classic Snake gameplay
- ⌨️ Arrow-key controls
- 🍎 Random food generation
- 📈 Snake grows after eating food
- 💥 Wall collision detection
▶️ Start game functionality- 🎨 Dynamic game-board rendering
- ⚡ Built using Vanilla JavaScript — no external libraries
- HTML5
- CSS3
- JavaScript (ES6+)
| Key | Action |
|---|---|
| ⬆️ Arrow Up | Move Up |
| ⬇️ Arrow Down | Move Down |
| ⬅️ Arrow Left | Move Left |
| ➡️ Arrow Right | Move Right |
Snake_Game_JavaScript/
│
├── index.html
├── style.css
├── script.js
└── README.md
git clone https://github.com/AKASH4213A/Snake_Game_JavaScript.gitNavigate into the project folder:
cd Snake_Game_JavaScriptOpen index.html in your browser.
You can also use the Live Server extension in VS Code for a better development experience.
This project was created to practice and understand:
- DOM Manipulation
- JavaScript Event Listeners
setInterval()- Arrays and Objects
- Keyboard Events
- Collision Detection
- Random Number Generation
- Dynamic CSS Classes
- Game Loop Logic
- Basic Game State Management
Credit goes to Sheriyansh coding school)
Some features that can be added in future versions:
- Score system
- High-score system
- Self-collision detection
- Increasing game speed
- Pause / Resume functionality
- Restart button
- Mobile touch controls
- Sound effects
- Difficulty levels
- Responsive mobile layout
![Snake Game Preview]
Akash Ahirwar
- GitHub: AKASH4213A
⭐ If you like this project, consider giving the repository a star!