NET FORGE DOCS

How to make a party game for 2 to 8 players on phones and laptops

Last updated Checked against @netforge/engine 0.2.0View as Markdown

Net Forge, the open-source multiplayer browser game engine built for AI coding agents, is published on npm under @netforge with source at github.com/netnetdev/net-forge.

Run npm create netforge@latest my-party -- --template party --yes and you have a party game: two to eight friends in one playroom, five quick rounds a show, each a minigame with one goal for the whole team, and touch controls so phones work. A minigame is a small object in the ROUNDS list of the show system in src/game.ts: a name, a length, what starts and what counts as a win.

npm create netforge@latest my-party -- --template party --yes
cd my-party
npm run play -- --host 0.0.0.0

With --host 0.0.0.0, everyone on the same network opens the link on their phone or laptop and joins the room.

What you get

PartWhereNotes
MinigamesROUNDS in the show system{ name, seconds, start(), won(), lastsOut }. The first four are shuffled each show; the finale is always last.
A showHIT_ATWin three rounds and the show is a hit; either way the next show starts.
Forgiving downsplayers.downedShort downs, a crawl, two free get-ups a show, everyone back between rounds.
The playroomgame({ field })One floor, four walls and party tables, bigger than the screen so crowds arrive off screen.
Touch controlstemplate clientEvery template plays on phones.
Server costmeasuredFour bots playing four minutes: 305 kills, 6 rounds, 0.42 ms per tick on average, p99 4.20 ms (Apple M2 Pro, Node 22).

1. Start it

npm create netforge@latest my-party -- --template party --yes
cd my-party
npm run play -- --players 2

2. Add a minigame

Inside the show system, append a round to ROUNDS. This one is won if nobody goes down for 35 seconds:

src/game.ts
{
  name: "DODGEBALL",
  seconds: 35,
  lastsOut: true,
  start: () => {
    spawnEdge("spritzer", { count: 6 + party() });
    every(4, () => { if (current === 5) spawnEdge("spritzer", { count: 2 }); });
  },
  won: () => false,
},

Its index in ROUNDS is its current value, and the shuffle leaves the last entry, the finale, where it is. won() is checked every half second and ends the round early when it returns true. Counters you can use include kills, downs, alive("prefab") and on("<prefab>.killed"). Keep 3 to 8 rounds, and give every round something to do every few seconds: a round with 30 quiet seconds fails the playtest as a softlock.

3. Reward the team

src/game.ts
import { earn } from "@netforge/engine";

earn.rule("first_win", { when: "round.won", n: 1, pay: 5, oncePer: "run" });
earn.rule("clean_sweep", { when: "show.perfect", n: 1, pay: 25, oncePer: "run" });

Every won round emits round.won, every round's end emits wave.cleared, and a clean sweep emits show.perfect. Locally all of it is play money.

4. Test it

npm test

The playtest plays shows with four bots and checks that rounds are decided, players level and nothing goes quiet.

How it works

The party game runs on the same action machinery as the survivor-like: the room is authoritative at 30 Hz, your own player is predicted, and weapons fire by themselves so every round is about where you stand and who you help up. The show is a system written in src/game.ts, not hidden machinery, so you and your agent can read every rule. See The typed game API and the party game template page.

Alternatives

  • Colyseus is an authoritative room server with matchmaking and state sync, and client SDKs for the web and several engines. Pick it when you have your own minigames and want a room server under them.
  • Godot exports to the web as WebAssembly with WebGL 2 and has a high-level multiplayer API. Pick it for an editor-first party game with a native build as well.

Pick Net Forge when you want a room of friends playing a finished co-op show within a minute, with minigames your agent can add.

FAQ

How many players can play together?

Two to eight in one room.

Do players need to install anything?

No. They open the link in a browser on a phone or laptop. Only the person hosting runs npm run play.

Is it competitive or co-op?

Co-op: each round has one goal for the whole team, and the show is a hit if the team wins three rounds.

How do I make a round easier?

Lower its goal, give it more seconds or smaller trickles, or lower HIT_AT. More selfRevives and a longer hitIframes help too.

Can I make the show longer?

Add rounds to ROUNDS (keep 3 to 8), or change ROUND_SECONDS, the default length of a round.