A real-time multiplayer chess game with voice chat, built using Node.js, Express, Socket.io, and chess.js. Play chess with friends or spectate games, all in your browser.
- Real-time Multiplayer Chess: Play chess with anyone by sharing a room ID.
- Spectator Mode: Join any room as a spectator if both player slots are filled.
- Live Board Updates: All moves are instantly reflected for all players and spectators.
- Drag-and-Drop Interface: Move pieces with intuitive drag-and-drop controls.
- Game State Sync: Join an ongoing game and instantly see the current board.
- Restart Game: Players can restart the game at any time.
- Voice Chat: Built-in peer-to-peer voice chat for players in the same room.
- Responsive UI: Works on desktop and mobile browsers.
-
Clone the repository:
git clone <your-repo-url> cd Chess
-
Install dependencies:
npm install
-
Build Tailwind CSS (if needed):
npx tailwindcss -i ./public/css/tailwind.css -o ./public/css/output.css --watch
You can skip this step if output.css is already present.
-
Start the server:
npm start
-
Open your browser and go to: http://localhost:3000
- Enter a Room ID:
- On page load, enter a unique Room ID to create or join a game room.
- Share the Room ID:
- Share the Room ID with your friend to play together.
- Player Roles:
- The first to join is White, the second is Black. Others join as spectators.
- Move Pieces:
- Drag and drop pieces to make moves. Legal moves are enforced.
- Restart Game:
- Players can restart the game using the Restart button.
- Voice Chat:
- Click 'Start Voice' to enable voice chat. Allow microphone access when prompted.
- Use 'Mute' to toggle your microphone.
app.js— Main server file (Express + Socket.io)public/— Static assets (CSS, JS)js/chessgame.js— Frontend logic for chess and voice chatcss/— Tailwind CSS files
views/index.ejs— Main HTML templatepackage.json— Project dependencies and scripts
- Node.js
- Express
- Socket.io
- chess.js
- EJS
- Tailwind CSS
- WebRTC (for voice chat)
Pull requests are welcome! For major changes, please open an issue first to discuss what you would like to change.