A real-time multiplayer game built with React and Socket.IO, featuring Among Us-style room lobbies and multiplayer gameplay.
- 🎮 Room-based Multiplayer: Create or join rooms with unique codes
- 👥 2-Player Support: Play with a friend in the same room
- 🚶 Real-time Movement: See other players move in real-time
- 🗺️ Collision Detection: Navigate around obstacles on the map
- 🎨 Beautiful UI: Modern gradient design with smooth animations
calhacks12/
├── backend/
│ ├── server.js # Socket.IO server
│ └── package.json
├── frontend/
│ ├── src/
│ │ ├── components/
│ │ │ ├── Lobby.jsx # Room creation/joining
│ │ │ ├── Lobby.css
│ │ │ ├── Game.jsx # Main game component
│ │ │ └── Game.css
│ │ ├── App.jsx
│ │ ├── App.css
│ │ ├── main.jsx
│ │ └── index.css
│ ├── public/
│ │ ├── img/
│ │ │ ├── calhacks-map.png
│ │ │ ├── calhacks-map-foreground.png
│ │ │ └── ninja.png
│ │ └── data/
│ │ └── collisions.js
│ ├── package.json
│ ├── vite.config.js
│ └── index-react.html
└── README.md
- Navigate to the backend directory:
cd backend- Install dependencies:
npm install- Start the server:
npm startThe server will run on http://localhost:3001
- Open a new terminal and navigate to the frontend directory:
cd frontend- Install dependencies:
npm install- Start the development server:
npm run devThe frontend will run on http://localhost:5173
- Open
http://localhost:5173in your browser - Click "Create Room"
- Enter your username
- You'll receive a unique 6-character room code
- Share this code with your friend
- Open
http://localhost:5173in another browser window/tab - Click "Join Room"
- Enter your username
- Enter the room code from the host
- Click "Join Room"
- Once both players are in the room, the host can click "Start Game"
- Both players will see the game map
- Use W, A, S, D keys to move your character
- You'll see your friend's character moving in real-time!
- W - Move Up
- A - Move Left
- S - Move Down
- D - Move Right
The backend uses Socket.IO to handle:
- Room creation and management
- Player join/leave events
- Real-time position synchronization
- Game state management
The frontend uses:
- React for component-based UI
- Socket.IO Client for real-time communication
- HTML Canvas for game rendering
- Vite for fast development and building
- Room Management: Unique room codes, host controls, player limits
- Real-time Sync: Player positions updated 60 times per second
- Collision Detection: Prevents players from walking through walls
- Sprite Animation: Animated walking sprites in 4 directions
- Username Display: See player names above their characters
- Make sure port 3001 is not in use
- Check that all dependencies are installed (
npm install)
- Verify the backend is running on port 3001
- Check the Socket.IO URL in
frontend/src/components/Lobby.jsx
- Ensure all image files are in
frontend/public/img/ - Check that
collisions.jsis infrontend/public/data/ - Make sure file paths are correct
- Check browser console for errors
- Verify both players are in the same room
- Make sure the game has been started by the host
- Support for more than 2 players
- Chat system
- Different character skins
- Game objectives/tasks
- Mobile support with touch controls
- Sound effects and background music
- React 18.2
- Socket.IO 4.7
- Express 4.18
- Vite 5.0
- HTML5 Canvas
MIT License - Feel free to use this project for learning and fun!