Snake Game (Vite Edition) is a modern, interactive remake of the timeless arcade classic. Built with Vite for lightning-fast performance, it delivers smooth animations, responsive controls, and fluid gameplay that feels natural on any screen size.
With multiple grid sizes, theme presets, and scalable difficulty, this project combines nostalgia with modern web design principles. Whether you're chasing your next high score or exploring the code, this reimagined version of Snake showcases the beauty of clean, modular, and performance-driven game development on the web.
- Classic Gameplay: Traditional Snake mechanics with modern enhancements
- Multiple Grid Sizes: Choose from Small (15ร15), Medium (20ร20), or Large (30ร30) play areas
- Smooth Animations: 60 FPS gameplay with fluid snake movement
- Responsive Controls: Keyboard arrow keys and WASD support
- Score System: Real-time score tracking with high score persistence
- Modern UI: Clean, minimalistic design with smooth transitions
- Progressive Difficulty: Game speed increases as snake grows longer
- Local Storage: Persistent high score storage across sessions
- Responsive Design: Works seamlessly on desktop and mobile devices
- Small (15ร15): Easy mode with more space to maneuver - perfect for beginners
- Medium (20ร20): Balanced classic experience - the traditional Snake game feel
- Large (30ร30): Hard mode with tight spaces requiring high skill and precision
- ๐ Snake Movement: Smooth directional controls with collision detection
- ๐ Food System: Randomly spawned food items that grow the snake
- ๐ Collision Detection: Wall and self-collision game over mechanics
- ๐ Scoring: Points awarded for each food item consumed
- โก Speed Progression: Increasing difficulty as score grows
- ๐ High Score: Persistent leaderboard using localStorage
- Build Tool: Vite 5.0+ (Lightning-fast development)
- Frontend: Vanilla JavaScript (ES6+)
- Graphics: HTML5 Canvas API
- Styling: Modern CSS3 with Flexbox/Grid
- Bundling: Vite's optimized build system
- Development: Hot Module Replacement (HMR)
- Node.js 18.0 or higher
- npm or yarn package manager
- Modern web browser with Canvas support
git clone https://github.com/debugfest/snake-game.git
cd snake-game# Using npm
npm install
# Or using yarn
yarn install
# Or using pnpm
pnpm install# Using npm
npm run dev
# Or using yarn
yarn dev
# Or using pnpm
pnpm devThe game will be available at http://localhost:5173
# Using npm
npm run build
# Or using yarn
yarn build
# Or using pnpm
pnpm buildsnake-game/
โโโ public/ # Static assets
โ โโโ favicon.ico # Game favicon
โโโ src/ # Source code
โ โโโ js/ # JavaScript modules
โ โ โโโ game.js # Main game logic
โ โ โโโ snake.js # Snake class and mechanics
โ โ โโโ food.js # Food generation and rendering
โ โ โโโ utils.js # Utility functions
โ โโโ css/ # Stylesheets
โ โ โโโ style.css # Main styles
โ โ โโโ responsive.css # Mobile responsive styles
โ โโโ main.js # Entry point
โโโ index.html # Main HTML file
โโโ package.json # Dependencies and scripts
โโโ vite.config.js # Vite configuration
โโโ README.md # Project documentation
โโโ CONTRIBUTING.md # Contributing guidelines
โโโ CODE_OF_CONDUCT.md # Community standards
โโโ LICENSE # MIT License
- Arrow Keys: Move snake (โ โ โ โ)
- WASD Keys: Alternative movement controls
- Swipe Gestures: Swipe up, down, left, or right on mobile
- Space Bar: Pause/Resume game
- R Key: Restart game
- Start the Game: Open the application and press any arrow key to begin
- Control the Snake: Use arrow keys or WASD to change direction
- Eat Food: Guide the snake to consume red food items
- Avoid Collisions: Don't hit walls or the snake's own body
- Score Points: Each food item increases your score and snake length
- Beat High Score: Try to surpass your previous best performance
| Action | Points | Effect |
|---|---|---|
| Eat Food | +10 | Snake grows by 1 segment |
| Wall Collision | Game Over | Reset to start screen |
| Self Collision | Game Over | Reset to start screen |
| Speed Increase | Every 50 points | Game becomes faster |
### Vite Configuration
The project uses Vite's default configuration with:
- **Hot Module Replacement**: Instant updates during development
- **Optimized Builds**: Tree-shaking and code splitting
- **Asset Processing**: Automatic optimization of images and assets
- **Development Server**: Fast startup and rebuild times
## ๐จ Customization
### Game Settings
Modify game parameters in `src/js/game.js`:
```javascript
const CONFIG = {
GRID_SIZE: 20, // Size of game grid
INITIAL_SPEED: 200, // Starting game speed (ms)
SPEED_INCREASE: 10, // Speed increase per level
POINTS_PER_FOOD: 10 // Points awarded per food
};
Customize appearance in src/css/style.css:
- Snake colors and animations
- Food appearance and effects
- UI theme and typography
- Canvas styling and borders
We welcome contributions!
- ๐ฎ Game Features: Power-ups, obstacles, multiplayer modes
- ๐จ Visual Effects: Animations, particle systems, themes
- ๐ฑ Mobile Support: Touch controls and responsive design
- โก Performance: Optimization and smooth gameplay
- ๐งช Testing: Unit tests and game logic validation
- ๐ Documentation: Tutorials and code examples
- Fork the repository
- Create feature branch (
git checkout -b feature/new-powerup) - Install dependencies (
npm install) - Start development server (
npm run dev) - Make changes and test thoroughly
- Commit with descriptive messages
- Push and create Pull Request
- Vite Team for the amazing build tool
- MDN Web Docs for Canvas API documentation
- Classic Snake Game creators for the timeless gameplay
- Open source community for inspiration and support
- All contributors who help improve this project
โญ If you found this project fun, please give it a star! โญ
Made with โค๏ธ
๐ Enjoy the classic Snake experience! ๐ฎ