1392e5a6526bf277228ff9bb3a30bc9f6cd1604d
- Fix room.state.players undefined error on component mount - Wait for initial state sync before accessing room data - Move message handlers from service to Game component - Fix player count display in waiting screen (was showing 0/2) - Prevent lobby component from clearing game room on unmount - Separate leaveLobby() and leaveGame() methods for proper cleanup - Ensure player names persist when moving from lobby to game - Add proper error handling for state initialization
Snatch Game - Competitive Clicker
A real-time multiplayer competitive clicker game built with Colyseus.js and Vue 3.
Features
- 🎮 Real-time multiplayer gameplay
- 🏆 10-minute competitive clicking battles
- 👥 2 players per room with automatic matchmaking
- 🎯 Unique player naming system with auto-increment
- 🎛️ Admin dashboard for game management
- 📊 Real-time statistics and monitoring
- 🔄 Automatic reconnection support
- ⏸️ Pause/Resume/Restart game controls
Tech Stack
- Backend: Colyseus.js, Express, TypeScript
- Frontend: Vue 3, Vite, TypeScript
- Real-time: WebSockets
- Styling: Custom CSS
Installation
# Install all dependencies
npm run install:all
Development
# Start both server and client in development mode
npm run dev
This will start:
- Server on http://localhost:3000
- Client on http://localhost:5173
URLs
- Game: http://localhost:5173
- Admin Dashboard: http://localhost:5173/dashboard
- Colyseus Monitor: http://localhost:3000/colyseus
- API Endpoints: http://localhost:3000/api
Project Structure
snatchgame/
├── server/ # Backend Colyseus server
│ ├── src/
│ │ ├── rooms/ # Game and Lobby rooms
│ │ ├── schemas/ # State schemas
│ │ ├── utils/ # Utilities (name manager)
│ │ ├── adminApi.ts # Admin REST API
│ │ └── index.ts # Server entry point
│ └── package.json
│
├── client/ # Frontend Vue application
│ ├── src/
│ │ ├── views/ # Vue components (Lobby, Game, Dashboard)
│ │ ├── services/ # Colyseus client service
│ │ ├── router/ # Vue Router
│ │ └── main.ts # App entry point
│ └── package.json
│
└── shared/ # Shared types between client and server
└── types.ts
Game Rules
- Players enter the lobby and choose a username
- Click "Quick Play" to join or create a game room
- Game starts when 2 players join a room
- Players have 10 minutes to click as fast as possible
- The player with the most clicks wins
- Games automatically restart after finishing
Admin Dashboard
The admin dashboard provides:
- View all active rooms and their status
- Pause/Resume games in progress
- Restart games
- Kick players from rooms
- View real-time statistics
- Monitor server performance
API Endpoints
GET /api/rooms- List all active roomsGET /api/rooms/:roomId/stats- Get room statisticsPOST /api/rooms/:roomId/pause- Pause a gamePOST /api/rooms/:roomId/resume- Resume a gamePOST /api/rooms/:roomId/restart- Restart a gamePOST /api/rooms/:roomId/kick/:playerId- Kick a playerGET /api/stats- Get global server statistics
Description
Languages
Vue
66.8%
TypeScript
26.6%
Mermaid
3.2%
Shell
2.2%
JavaScript
0.6%
Other
0.6%