This is a real-time multiplayer implementation of the classic Snake game built using Python (Flask/SocketIO) for the backend and JavaScript/HTML/CSS for the frontend. It supports multiple players in a single room, competitive scoring, and optional map modes (restricted boundaries or open-world wrap-around).
- Real-time Multiplayer: Uses SocketIO for low-latency communication and smooth gameplay.
- Dynamic Rooms: Players can create or join unique game rooms.
- Competitive Play: Snakes collide with walls, their own bodies, or other snakes, leading to a reset/respawn.
- Scoreboard: Tracks and displays scores of all players in the room.
- Map Modes: Supports both Area Restricted (walls kill) and Open World (wrap-around) modes.
- Sound Effects: Includes sounds for eating, respawning, button clicks, and game over.
- Network Accessible: Configured to be accessible by other devices on the same local network.
Follow these steps to get the game running on your machine.
You must have Python 3 installed. The necessary Python libraries are listed in requirements.txt:
FlaskFlask-SocketIOpython-socketioeventlet
Navigate to the project root directory in your terminal and install the required packages:
pip install -r requirements.txtStart the application by executing the Python server file:
python "Multiplayer Snake Game/server.py"The console will output a message indicating the server is running and listening on Port 5000.
The server is configured to run on 0.0.0.0, which allows all devices on the same local network (like your phone or a friend's laptop) to connect.
To join, you need the local IP address of the computer running the server.
| Operating System | Command to Use in Terminal/Command Prompt | Look For | Example Address |
|---|---|---|---|
| Windows | ipconfig |
IPv4 Address | 192.168.1.10 |
| macOS / Linux | ifconfig or ip a |
inet address under your active network interface (e.g., en0 or wlan0) |
192.168.1.10 |
Once you have the local IP address (e.g., 192.168.1.10), any device connected to the same Wi-Fi/router can access the game by opening a web browser and navigating to the following address:
http://[Your.Local.IP.Address]:5000
(Example: http://192.168.1.10:5000)
- Create a Room: On one device, enter a name, choose a map mode, and click "Create Room".
- Share Link: The creator gets an invite link with the Room ID embedded. Share this link (or just the Room ID) with others.
- Join the Game: Other players enter their name, the Room ID, and click "Join".
- Start: The game will automatically start once the minimum number of players (2) has joined.
- Controls: Use the W, A, S, D keys or Arrow Keys to change your snake's direction.
Multiplayer Snake Game/
├── server.py # Main Python Flask/SocketIO server logic.
├── requirements.txt # Python dependencies.
├── credits.md # Sound effect attributions.
├── static/
│ ├── css/
│ │ └── style.css # Game styling.
│ ├── js/
│ │ ├── main.js # Frontend game rendering and logic.
│ │ └── networking.js # SocketIO connection and room handling, includes sound logic.
│ └── sounds/
│ ├── buttonClick.mp3 # UI sound.
│ ├── eat.mp3 # Apple eaten sound.
│ ├── gameOver.mp3 # Game over/leave room sound.
│ └── respawn.mp3 # Player snake reset sound.
└── templates/
└── index.html # Main and only frontend page.