- Add real-time multiplayer game server with Colyseus - Implement unique player naming system with auto-increment - Create lobby system with automatic matchmaking - Build 10-minute competitive clicking game rooms (max 2 players) - Add admin dashboard for game management (pause/resume/restart/kick) - Implement Vue 3 client with professional UI - Add WebSocket communication with state synchronization - Include TypeScript throughout with proper typing - Create REST API for admin operations - Add reconnection support and error handling
2.9 KiB
2.9 KiB
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