A real-time multiplayer Rock Paper Scissors game built with HTML, CSS, JavaScript for the frontend, and Node.js with Express and WebSockets for the backend.
- 🎮 Real-time multiplayer gameplay using WebSockets
- 👥 Player matching system
- 📊 Score tracking across multiple rounds
- 🎯 Visual feedback for choices and results
- 🔄 Play again functionality
- 📱 Responsive design
- HTML5
- CSS3 (with animations and gradients)
- Vanilla JavaScript
- Node.js
- Express.js
- Socket.io (WebSocket library)
rock-paper-scissors/
├── public/
│ ├── index.html # Main HTML file
│ ├── style.css # Styling for the game
│ └── client.js # Frontend JavaScript logic
├── server.js # Node.js/Express server with Socket.io
├── package.json # Project dependencies and scripts
└── README.md # This file
-
Clone or download the project files
# If using git git clone <repository-url> cd rock-paper-scissors
-
Install dependencies
npm install
-
Start the server
npm start
-
For development with auto-restart:
npm run dev
-
Open your browser
- Navigate to
http://localhost:3000
- Navigate to
-
Test multiplayer functionality
- Open another browser window/tab to play against yourself
- Enter your name and click "Join Game"
- Wait for the system to match you with another player
- When a game starts, choose Rock, Paper, or Scissors
- The game plays best of 3 rounds
- After completion, you can choose to play again
- Rock beats Scissors
- Scissors beats Paper
- Paper beats Rock
- Matching choices result in a draw
joinGame- Join the waiting queuemakeChoice- Submit a player's choiceplayAgain- Request to play another gamecancelWaiting- Cancel waiting for an opponent
playerCount- Update on number of connected playerswaitingForOpponent- Notification when waiting for matchgameStarted- Notification when game beginsroundResult- Result of each roundgameOver- Final game resultplayAgain- Reset game for another rounderror- Error notifications
express: ^4.18.2 - Web server frameworksocket.io: ^4.7.2 - WebSocket library for real-time communication
nodemon: ^3.0.1 - Utility that automatically restarts node application
You can modify these aspects of the game:
- Number of rounds: Change the
maxRoundsvalue inserver.js - Styling: Modify colors and styles in
style.css - Game rules: Adjust the
rulesobject inserver.js - Player timeout: Add disconnect handling for inactive players
- Port already in use: Change the
PORTvariable inserver.js - Connection issues: Ensure no firewall is blocking port 3000
- Game not matching players: Refresh both browser windows
This game works on all modern browsers that support:
- ES6 JavaScript features
- CSS Flexbox
- WebSockets
Potential improvements for this game:
- User authentication and profiles
- Game rooms with custom settings
- Chat functionality between players
- Tournament mode with multiple players
- Mobile app version using the same backend
This project is open source and available under the MIT License.