A real-time multiplayer web game inspired by Slither.io, built with PIXI.js for the frontend and Node.js with WebSockets for the backend.
- Real-time multiplayer gameplay - Play with multiple players simultaneously
- Snake mechanics - Control your snake, eat food to grow, and avoid other snakes
- AI opponents - Battle against AI-controlled snakes for more dynamic gameplay
- Food system - Collect food pellets to grow your snake and increase your score
- Collision detection - Advanced physics system with collision detection for snake interactions
- Smooth rendering - High-performance 2D graphics powered by PIXI.js
- Responsive controls - Mouse-based movement controls for precise snake navigation
The project consists of two main components:
- Framework: PIXI.js for 2D graphics rendering
- Build Tool: Vite for fast development and building
- Language: Vanilla JavaScript (ES6 modules)
- Features: Real-time rendering, input handling, asset management
- Runtime: Node.js
- WebSocket: Native WebSocket implementation for real-time communication
- Game Engine: Custom game world implementation with physics simulation
- Data Format: MessagePack for efficient binary data transmission
- Node.js (v14 or higher)
- npm or yarn package manager
-
Clone the repository
git clone <repository-url> cd slither(pixi)
-
Install client dependencies
cd client npm install -
Install server dependencies
cd ../server npm install
-
Start the server
cd server npm startThe server will start on
http://localhost:3000 -
Start the client
cd client npm run devThe client will be available at
http://localhost:5500 -
Open your browser and navigate to the client URL to start playing!
- Start the game by clicking the "Start" button
- Control your snake by moving your mouse cursor - your snake will follow the mouse
- Eat food pellets (small colored circles) to grow your snake and increase your score
- Avoid other snakes - hitting another snake's body will cause you to die
- Survive and grow to become the largest snake on the field!
├── client/ # Frontend application
│ ├── src/
│ │ ├── game.js # Main game logic and rendering
│ │ ├── main.js # Application initialization
│ │ ├── network/ # WebSocket communication
│ │ ├── utils/ # Utility functions (physics, assets, etc.)
│ │ └── images/ # Game assets and sprites
│ ├── index.html # Main HTML file
│ └── package.json # Client dependencies
├── server/ # Backend application
│ ├── worlds/ # Game world implementations
│ ├── objs/ # Game object classes
│ ├── core/ # Core game systems
│ ├── index.js # Server entry point
│ └── package.json # Server dependencies
└── README.md # This file
- Game World (
server/worlds/slither-io.js): Main game logic including snake management, food spawning, and collision detection - Snake Manager (
server/objs/snake.js): Handles snake creation, movement, and physics - Client Game (
client/src/game.js): Frontend rendering and game state management - WebSocket Handler (
client/src/network/socket.js): Real-time communication with server
Client:
cd client
npm run buildServer: The server runs directly with Node.js - no build step required.
Create a .env file in the server directory:
PORT=3000
USE_SSL=FALSEKey game parameters can be adjusted in server/worlds/slither-io.js:
food_limit: Maximum number of food pelletssnake_min: Minimum number of AI snakes- World dimensions and physics parameters
Common Issues:
- Port conflicts: Ensure ports 3000 and 5500 are available
- WebSocket connection issues: Check that both client and server are running
- Performance issues: Monitor browser console for rendering performance warnings
Debug Mode:
- Enable debug logging by uncommenting console.log statements in the server code
- Use browser developer tools to monitor WebSocket connections and game performance
- Fork the repository
- Create a feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'Add some amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
This project is licensed under the MIT License - see the LICENSE file for details.
- Inspired by the original Slither.io game
- Built with PIXI.js for high-performance 2D graphics
- Uses Node.js and WebSockets for real-time multiplayer functionality
Have fun playing and developing! 🐍✨