A minimalist black and white web-based multiplayer version of Pocket Tanks.
npm install
npm startThen open http://localhost:5173 in multiple browser tabs!
- 🎮 Real-time multiplayer - each browser tab = new player
- 🎯 Friendly player names - 20 unique names like "Tank Commander", "Artillery Ace"
- ⚡ Vite with HMR - instant code updates
- 🎯 Server-authoritative - no cheating possible
- ⏱️ Auto-disconnect - removes idle players after 60s
- 🧹 Clean player removal - proper WebSocket cleanup and name recycling
- 🏔️ Destructible terrain - explosions crater the ground
- 🎨 Black/white line art - minimalist aesthetic
When you run npm start:
- Vite starts on port 5173 (serves the game UI with HMR)
- WebSocket server starts on port 3000 (handles multiplayer logic)
- Open multiple tabs → each becomes a new player
- Players take turns automatically
| Key | Action |
|---|---|
| A/D | Move tank left/right |
| W/S | Adjust turret angle |
| Q/E | Adjust shot power |
| SPACE | Fire missile |
| U | End turn manually |
- Each player: 5 bullets, 4 moves, 100 health
- Only the active player can control their tank
- Physics-based projectiles with gravity
- Direct hits deal more damage
- Terrain is destructible
- Idle 60s = auto-disconnect
Optional .env file:
PORT=3000 # WebSocket server port
IDLE_TIMEOUT=60000 # Idle timeout in millisecondsnpm start # Start Vite + WebSocket server
npm test # Test WebSocket connections
npm run test:cleanup # Test cleanup & name recycling┌──────────────────┐ ┌───────────────────┐
│ Browser Tab 1 │ │ │
│ localhost:5173 │◄───WS───►│ WebSocket Server │
├──────────────────┤ │ localhost:3000 │
│ Browser Tab 2 │◄───WS───►│ │
│ localhost:5173 │ │ • Game logic │
├──────────────────┤ │ • Physics (60fps)│
│ Browser Tab N │◄───WS───►│ • Idle tracking │
└──────────────────┘ └───────────────────┘
Vite Plugin: Automatically starts the WebSocket server when Vite starts, so you only need one command!
| File | Purpose |
|---|---|
server.js |
WebSocket server + game logic |
game.js |
Client rendering + WebSocket |
index.html |
Game UI |
style.css |
Styling |
vite.config.js |
Vite config + server plugin |
| Issue | Solution |
|---|---|
| Port 3000 in use | Set PORT=8080 in .env |
| Port 5173 in use | Change in vite.config.js |
| Disconnected | Server might not be running - check console |
| Auto-disconnect | 60s idle - stay active! |
Built with Node.js + WebSockets + Vite