A Node.js backend for a real-time multiplayer drawing and guessing game.
acmdraws-backend is the server-side application that powers a multiplayer drawing and guessing game inspired by skribbl.io. It handles game logic, player management, real-time communication using WebSockets, and serves game assets.
- Real-time Multiplayer: Supports multiple players in a room.
- Room Management: Create public or private game rooms.
- Game Logic: Manages rounds, turns, word selection, drawing, guessing, and scoring.
- WebSocket Communication: Uses Socket.IO for real-time updates between clients and server.
- Customizable Game Settings: Allows hosts to configure rounds, draw time, and custom words.
- Word Dictionary: Includes a default dictionary and supports custom word lists.
- Player Avatars: Basic avatar support for players.
- Chat Functionality: In-game chat for players.
- Hint System: Provides hints during the drawing phase.
- Server Configuration: Allows for maintenance mode and other server-side settings.
- Health Check Endpoint:
/healthendpoint to monitor server status.
- Node.js: JavaScript runtime environment.
- Express.js: Web application framework for Node.js.
- Socket.IO: Library for real-time, bidirectional and event-based communication.
-
Clone the repository:
git clone https://github.com/ACM-VIT/acmdraws-backend cd acmdraws-backend -
Install dependencies:
npm install
-
Configure the server (optional): Modify
server.jsfor server-specific settings in theSERVER_CONFIGobject. -
Run the server:
npm start
The server will typically run on
http://localhost:3001or the port specified in yourProcfileor environment variables.
GET /health: Returns the health status of the server.GET /api/config: Returns the current server configuration.
The server uses Socket.IO to handle various game events. Key events include:
identifyUser: Client identifies itself to the server.createRoom: Client requests to create a new game room.joinRoom: Client requests to join an existing game room.startGame: Host starts the game with specified settings.selectWord: Drawer selects a word to draw.drawing: Drawer sends drawing data.chatMessage: Client sends a chat message or guess.leaveRoom: Client leaves the current room.getPublicRooms: Client requests a list of public rooms.clearCanvas: Drawer clears the canvas.
The server emits events like:
serverConfig: Sends server configuration to the client.roomCreated: Confirms room creation.joinedRoom: Confirms player has joined a room.playerJoined: Notifies room about a new player.playerLeft: Notifies room when a player leaves.gameStarted: Notifies clients that the game has started.wordSelection: Sends word options to the drawer.roundStart: Notifies clients that a new round/turn has started.timeUpdate: Sends remaining time updates.drawingData: Broadcasts drawing data to clients in the room.chatMessage: Broadcasts chat messages.wordGuessed: Notifies a player their guess was correct.turnEnded: Notifies clients that the current turn has ended.gameEnded: Notifies clients that the game has ended.errorMessage: Sends an error message to a client.publicRooms: Sends a list of public rooms.canvasCleared: Notifies clients that the canvas has been cleared.wordHint: Sends a hint for the current word.
- Using Git for version control and code management.
- Follow standard Gitflow or a similar branching model.
- Push to feature branches and create pull requests for review before merging into
masterordevelopmentbranches.
