A modern HTML5 multiplayer Snake game with AI opponents, built with vanilla JavaScript and ES6 modules.
- Multiplayer: 1 player vs 3 AI opponents
- Modern Graphics: HTML5 Canvas with smooth animations
- AI System: Intelligent AI with pathfinding algorithms
- Responsive Design: Centered game view with window alignment
- Real-time Gameplay: 60 FPS rendering with optimized performance
- Visual Effects: Glowing snakes, animated apples, and smooth animations
- Use Arrow Keys or WASD to control your snake (green)
- Eat red apples to grow and increase your score
- Avoid walls, your own tail, and other snakes
- Survive longer than the AI opponents to win!
- Game ends when only one snake remains or time runs out
โโโ index.html # Main game page
โโโ css/
โ โโโ styles.css # Game styling
โโโ js/
โโโ main.js # Application entry point
โโโ engine/ # Core game engine
โ โโโ GameEngine.js # Main game coordinator
โ โโโ GameState.js # Game state management
โ โโโ GameLoop.js # Frame-based game loop
โโโ entities/ # Game objects
โ โโโ Snake.js # Base snake class
โ โโโ PlayerSnake.js # Human player
โ โโโ AISnake.js # AI opponent
โโโ systems/ # Game systems
โโโ Renderer.js # Canvas rendering
โโโ InputSystem.js # Input handling
โโโ AISystem.js # AI decision making
โโโ CollisionDetector.js # Physics
โโโ AppleManager.js # Food spawning
- ES6 Modules: Modern JavaScript architecture
- Canvas 2D API: High-performance rendering
- Object-Oriented Design: Clean, maintainable code structure
- Pathfinding AI: Smart AI opponents with strategic behavior
- Responsive Layout: Automatic window centering and scaling
-
Clone the repository:
git clone https://github.com/ayggdrasil/multiplayer-snake-game.git cd multiplayer-snake-game -
Start a local server:
# Using Python python3 -m http.server 8080 # Using Node.js npx serve . # Using PHP php -S localhost:8080
-
Open your browser: Navigate to
http://localhost:8080
- Map Size: 32ร32 grid (1,024 cells)
- View Size: 55% of canvas for optimal gameplay
- Game Duration: 5 minutes maximum
- Frame Rate: 60 FPS rendering, 10 FPS game logic
- Players: 1 human + 3 AI opponents
-
Victory Conditions:
- Last snake alive wins
- Highest score when time expires
-
Death Conditions:
- Hit wall boundaries
- Hit your own tail
- Head-to-head collision (smaller snake dies)
- Head-to-body collision
-
Scoring:
- +1 point per apple eaten
- Longer survival = better ranking
- Pathfinding: A* algorithm for optimal apple collection
- Collision Avoidance: Smart obstacle detection
- Strategic Positioning: Corner-based starting positions
- Adaptive Difficulty: AI scales with game progression
- Chrome/Chromium 60+
- Firefox 55+
- Safari 12+
- Edge 79+
Game settings can be modified in js/engine/GameState.js:
- Map dimensions
- Game speed
- Timer duration
- Visual effects
MIT License - feel free to fork and modify!
- Fork the repository
- Create a feature branch
- Make your changes
- Test thoroughly
- Submit a pull request
- Online multiplayer support
- Power-ups and special abilities
- Customizable snake skins
- Leaderboard system
- Mobile touch controls
- Sound effects and music
Built with โค๏ธ using vanilla JavaScript and HTML5 Canvas