multiplayer added
This commit is contained in:
1 parent
df91e0aff8
commit
50718059e0
19 files changed
+1144
-111
No files matched your search
@@ -8,10 +8,57 @@ A modern [Scorched Earth](https://en.wikipedia.org/wiki/Scorched_Earth_(video_ga
|
||||
|
||||
## How to play
|
||||
|
||||
Tanks take turns to shoot at other tanks. The last surviving tank wins the round. Player 1 (red) is controlled via the keyboard, while other players are randomly-picked AIs.
|
||||
Tanks take turns to shoot at other tanks. The last surviving tank wins the round. Player 1 (red) is controlled via the keyboard, while other players are randomly-picked AIs. You can also play online against friends (see [Multiplayer](#multiplayer)).
|
||||
|
||||
Use the start menu to configure players (3-10), rounds (1-10), and terrain type before each battle. Between rounds, visit the market to spend your score on weapons.
|
||||
|
||||
## Multiplayer
|
||||
|
||||
Play over the internet (or LAN) with up to 6 human players; the remaining slots are filled by AIs. The game uses a **host-authoritative** model: one player's browser runs the simulation, a tiny Node.js relay forwards messages between players, and the other players render from synchronized snapshots.
|
||||
|
||||
### Running the relay
|
||||
|
||||
```sh
|
||||
cd server
|
||||
npm install
|
||||
PORT=8090 npm start
|
||||
```
|
||||
|
||||
### Playing
|
||||
|
||||
1. Open the game and set **Mode → Multiplayer** in the start menu.
|
||||
2. Pick **HOST GAME** to create a room — you'll get a 6-character room code. The host configures total players, rounds, and terrain in the lobby, then presses START GAME.
|
||||
3. Other players pick **JOIN GAME** and enter the code (plus their name).
|
||||
4. Play as usual: aim, fire, and shop in the market. The host's browser simulates the game for everyone; other players can take their turns from anywhere.
|
||||
|
||||
### Hosting options
|
||||
|
||||
- **Same machine as the game** (default): the relay URL is derived from the page URL, so a reverse proxy can forward `/ws` to the relay port.
|
||||
- **Dev/LAN override**: point the game at any relay with `?relay=ws://HOST:PORT` (e.g. `http://localhost:8123/?relay=ws://localhost:8090`).
|
||||
|
||||
Example nginx location for the WebSocket endpoint:
|
||||
|
||||
```nginx
|
||||
location /ws {
|
||||
proxy_pass http://127.0.0.1:8090;
|
||||
proxy_http_version 1.1;
|
||||
proxy_set_header Upgrade $http_upgrade;
|
||||
proxy_set_header Connection "upgrade";
|
||||
}
|
||||
```
|
||||
|
||||
### How it works (short)
|
||||
|
||||
- The relay (`server/server.js`) only routes messages: joins, rosters, commands (client → host), and broadcasts (host → clients). It holds no game state.
|
||||
- The host broadcasts a world snapshot on every state change (and every 100–250 ms during projectile/explosion resolution), plus the terrain bitmap as a PNG whenever it changes (craters, collapse, napalm).
|
||||
- Clients render by applying snapshots to the same game code; they simulate nothing, and their aim/fire/market actions are sent as commands to the host.
|
||||
|
||||
### Control flow
|
||||
|
||||
- Turn-based rounds, market economy, and scoring work exactly as in single-player.
|
||||
- If a remote player doesn't fire within 45 seconds of their turn starting, the host auto-fires for them.
|
||||
- If the host leaves, the game ends for everyone.
|
||||
|
||||
### Controls
|
||||
|
||||
| Key | Function | With Shift | With Alt |
|
||||
@@ -46,8 +93,8 @@ Use the start menu to configure players (3-10), rounds (1-10), and terrain type
|
||||
- [ ] Many different tanks to pick from
|
||||
- [ ] Many AIs to battle against (only Moron and Chooser implemented)
|
||||
- [ ] Configuration
|
||||
- [ ] Local Multiplayer
|
||||
- [ ] Internet Multiplayer
|
||||
- [X] Local Multiplayer
|
||||
- [X] Internet Multiplayer (host-authoritative, via `server/` relay)
|
||||
|
||||
## What's new
|
||||
|
||||
@@ -58,6 +105,7 @@ This fork adds significant enhancements over the original game:
|
||||
- Multi-round battles with persistent score tracking and weapon purchasing
|
||||
- Improved visual effects: lava explosions, enhanced flame animation, and particle effects
|
||||
- Napalm and Hot napalm weapons
|
||||
- Online multiplayer (up to 6 humans + AI fill) with a Node.js relay server
|
||||
|
||||
## Weapons
|
||||
|
||||
|
||||
Reference in new issue
Block a user