https://github.com/pavi2410/imposter3d
https://github.com/pavi2410/imposter3d
Last synced: 7 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/pavi2410/imposter3d
- Owner: pavi2410
- Created: 2025-02-27T18:15:08.000Z (7 months ago)
- Default Branch: main
- Last Pushed: 2025-02-28T00:03:05.000Z (7 months ago)
- Last Synced: 2025-02-28T04:23:29.638Z (7 months ago)
- Language: JavaScript
- Size: 55.7 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Imposter3D
A 3D multiplayer game inspired by Among Us, built with React Three Fiber and Socket.IO.
## Project Structure
This project uses a monorepo structure with the following packages:
### packages/client
The frontend application built with:
- React 19
- Three.js
- React Three Fiber (@react-three/fiber)
- React Three Drei (@react-three/drei)
- Socket.IO Client
- Vite as the build toolThe client handles game rendering, player movement, tasks, and impostor actions.
### packages/server
The backend server built with:
- Node.js
- Socket.IOThe server manages game rooms, player connections, game state, and synchronizes player actions across clients.
### packages/shared
Shared code and constants used by both client and server, including:
- Player colors
- Game configuration
- Shared types and interfaces## Socket.IO Protocol
The game uses Socket.IO for real-time communication between clients and server. Here are the main events:
### Client to Server Events
| Event | Payload | Description |
|-------|---------|-------------|
| `createRoom` | `{ name, color }` | Creates a new game room with player customization |
| `joinRoom` | `roomCode, { name, color }` | Joins an existing room with the given code |
| `leaveRoom` | - | Leaves the current room |
| `startGame` | - | Starts the game (host only) |
| `updatePlayer` | `{ position, rotation }` | Updates player position and rotation |
| `killPlayer` | `targetId` | Impostor action to kill another player |
| `completeTask` | `taskId` | Marks a task as completed |
| `updateCustomization` | `{ name, color }` | Updates player customization |### Server to Client Events
| Event | Payload | Description |
|-------|---------|-------------|
| `roomCreated` | `roomCode` | Confirms room creation with room code |
| `joinedRoom` | `roomCode, players` | Confirms room join with room code and existing players |
| `playerJoined` | `playerId, playerData` | Notifies when a new player joins |
| `playerLeft` | `playerId` | Notifies when a player leaves |
| `gameStarted` | - | Notifies that the game has started |
| `roleAssigned` | `{ isImpostor }` | Assigns player role (impostor or crewmate) |
| `playerUpdate` | `playerId, position, rotation` | Updates other players' positions |
| `playerKilled` | `playerId` | Notifies when a player is killed |
| `taskCompleted` | `taskId, playerId` | Notifies when a task is completed |
| `gameOver` | `{ winner }` | Notifies game end with winner ('crewmates' or 'impostors') |
| `error` | `message` | Sends error messages to client |## Installation
### Prerequisites
- [Bun](https://bun.sh/) (JavaScript runtime and package manager)
### Setup
1. Clone the repository
```bash
git clone https://github.com/yourusername/imposter3d.git
cd imposter3d
```2. Install dependencies
```bash
bun install
```This will install dependencies for all packages in the workspace.
## Running the Application
### Development Mode
1. Start the server:
```bash
bun run server
```2. In a separate terminal, start the client:
```bash
bun run dev
```The client will be available at http://localhost:5173
### Production Build
1. Build the client:
```bash
bun run build
```2. Preview the production build:
```bash
bun run preview
```## Game Controls
- WASD: Move player
- Mouse: Look around
- E: Interact with tasks
- Q: Kill (Impostor only)## Features
- 3D multiplayer gameplay
- Player customization (name and color)
- Impostor and crewmate roles
- Task completion system
- Kill mechanics for impostors
- Room-based matchmaking