ramazancetinkaya /
snake-game
An implementation of the classic Snake game using HTML5, CSS, and JavaScript.
Loading repository data…
musthofa-kamaluddin / repository
Classic Snake Game is a modern, engaging take on the iconic Snake game, crafted with vanilla JavaScript, HTML5 Canvas, and CSS3. Designed by Musthofa Kamaluddin, this responsive game combines retro pixel art aesthetics with smooth animations and intuitive controls, ensuring a seamless experience across desktop and mobile devices.
A modern, responsive implementation of the classic Snake game built with vanilla JavaScript, HTML5 Canvas, and CSS3. Features smooth animations, multiple difficulty levels, and cross-platform compatibility.
Experience the game live: Play Snake Game
| Difficulty | Speed (ms) | Description |
|---|---|---|
| Easy | 150 | Perfect for beginners |
| Medium | 100 | Balanced gameplay |
| Hard | 70 | Challenge mode |
Clone the repository
git clone https://github.com/musthofa-kamaluddin/snake.git
cd snake
Launch the game
# Option 1: Open directly in browser
open index.html
# Option 2: Use local server (recommended)
python -m http.server 8000
# or
npx serve
Play!
http://localhost:8000 in your browser| Input | Action |
|---|---|
↑ W | Move Up |
↓ S | Move Down |
← A | Move Left |
→ D | Move Right |
| Touch/Swipe | Mobile controls |
snake/
├── index.html # Main HTML structure
├── styles.css # CSS styling and animations
├── game.js # Core game logic
└── README.md # Documentation
SnakeGame class)class SnakeGame {
constructor() // Initialize game state
gameLoop() // Main game loop using requestAnimationFrame
update() // Game state updates
draw() // Canvas rendering
collision() // Collision detection system
}
// Efficient game loop
gameLoop(currentTime) {
if (secondsSinceLastRender < 1 / (1000 / this.gameSpeed)) return;
this.update();
this.draw();
}
// Smart collision detection
if (this.snake.some(segment =>
segment.x === head.x && segment.y === head.y)) {
this.gameOver();
}
setupCanvas() {
const containerWidth = this.canvas.parentElement.clientWidth;
const size = Math.min(containerWidth - 40, 600);
this.canvas.width = size;
this.canvas.height = size;
this.cellSize = size / this.gridSize;
}
| Browser | Version | Support |
|---|---|---|
| Chrome | 60+ | ✅ Full |
| Firefox | 55+ | ✅ Full |
| Safari | 11+ | ✅ Full |
| Edge | 79+ | ✅ Full |
| Mobile Safari | 11+ | ✅ Touch |
| Chrome Mobile | 60+ | ✅ Touch |
:root {
--primary-color: #0f0; /* Neon green */
--bg-color: #000; /* Black background */
--border-width: 2px; /* UI borders */
--glow-intensity: 10px; /* Glow effects */
}
// Modify these values in game.js
this.gridSize = 20; // Grid dimensions
this.gameSpeed = 150; // Initial speed (ms)
this.scoreIncrement = 10; // Points per food
We welcome contributions! Here's how to get started:
git checkout -b feature/amazing-feature
git commit -m 'feat: add amazing feature'
git push origin feature/amazing-feature
Found a bug? Please create an issue with:
This project is licensed under the MIT License - see the LICENSE file for details.
MIT License
Copyright (c) 2024 Snake Game Project
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction...
Musthofa Kamaluddin
Enjoy the game! 🐍🎮
Selected from shared topics, language and repository description—not editorial ratings.
ramazancetinkaya /
An implementation of the classic Snake game using HTML5, CSS, and JavaScript.
RabiRoshan /
Classic nokia snake game using web.
LijoFelix /
Classic Snake game in the browser using HTML, CSS & JavaScript with scoring and increasing speed.
Agent-A345 /
A modern web-based implementation of the classic Snake Game, built using HTML5 Canvas, CSS, and JavaScript.
zayennn /
🐍 A classic Snake Game reimagined with HTML, CSS, and JavaScript. Guide the snake, eat the food, and grow longer without hitting yourself or the w
AzhaanGlitch /
Classic Snake Game: A timeless arcade experience rebuilt with pure HTML, CSS, and vanilla JavaScript. Maneuver your snake to gobble food, grow longer, and rack up points—while dodging walls and self-collisions. Simple, addictive, and fully responsive!