Feature Library

Wave director for action games

0.51 CPU ms
A still of the Wave director for action games demo
Still
The live demo starts when it’s in view.Play or drag the timeline to scrub the run · arrow keys on the timeline step five seconds · Restart and the busiest stretch under the controls

Who comes, how many, from where and when, over a run’s clock.

Who comes, how many, from where and when, over a run’s clock: a crowd curve as a share of the device’s cap, groups that arrive from just past the edge of the view on every side, named phases with their own mix of kinds, timed surges that close in as a ring, and set pieces from a chosen side. Headless and seeded, so the same seed plays the same run; it spawns through a callback and says what happened as events for banners, sounds and the live region.

See it live in Swarm run, the 2D action kit’s game →

What it costs a frame

0.51 ms
GPU
not used
CPU, median
0.51 ms
CPU, 95th pct
0.97 ms
Draw calls
0
Weight
Moderate

Measured 21 November 2026 on RTX 4060 Laptop, 13th Gen Intel(R) Core(TM) i9-13900H, Chrome 157, 1920×1080 at 1×. 600 frames × 3 rounds, median kept (rounds ranged CPU 0.50–0.53 ms). What ran: Alone, from 2:00 at 1× with a cap of 300 (the busiest stretch, a surge and a heavy arrival in it): the director’s update each frame, the demo’s plain crowd count, and the spawn marks and timeline drawn in Canvas 2D. Phones: tiers are being measured next.

How steadily it runs on RTX 4060 Laptop · 13th Gen Intel(R) Core(TM) i9-13900H · reference

Typical frame ?
16.86 ms
1% low ?
54 fps
Varies by ?
±0.48 ms
All metricsRTX 4060 Laptop · 13th Gen Intel(R) Core(TM) i9-13900H · reference
p50p95p9916.02 ms18.32 ms +
How long each frame took. Most frames sit in the tall bars; a long tail to the right is hitching.

Frames run on a 60 Hz timer (a page demo), so most frames take about one tick, 16.7 ms: the spread around it is what matters.

Frames

Median (p50) ?
16.86 ms
p95 ?
17.75 ms
p99 ?
18.25 ms
Slowest ?
18.96 ms
Mean ?
16.88 ms
Standard deviation ?
0.48 ms
1% low ?
54 fps
0.1% low ?
53 fps
Hitches ?
0 of 600
Over budget ?
0 of 600

Main thread

Long tasks ?
0
Long frames ?
0
Event-loop delay ?
0.1 / 0.9 / 1.2 ms

Input

No input during this run.

Memory

JavaScript heap ?
35.6 → 36.0 MB
Growth ?
+0.39 MB

Browser

JavaScript a frame ?
0.66 ms
All tasks a frame ?
1.18 ms
Layout / style ?
0.04 / 0.01 ms
Main thread busy ?
7%

Garbage collection

Collections ?
28 (28 minor, 0 major)
Pauses ?
12.2 ms in all, longest 1.6

What it needs

Renders with
Canvas 2DA 2D canvas: every current browser.
Your browser
Runs hereNo WebGPU needed
Depends on
NothingNo other packages
With an agent
install("wave-director")Your coding agent reads its pitfalls and installs it through the library’s MCP server. Set it up

What it’s for

  1. Swarm and survival games where the crowd builds over a run
  2. Tower defence and arena waves with named phases
  3. A boss or set piece at fixed times on the clock
  4. Pacing a run to a device’s budget (fewer on a phone, the same shape)
  5. Replays and balance tests that need the same run from a seed

Pitfalls, in brief

  1. Pass the real number alive every update: the director stops sending groups at the curve’s share of the cap and counts its own spawns within a step only.
  2. The cap is the device’s budget, not the design’s: give the phone tier a smaller cap and the run keeps its shape (the curve is a share).
  3. Groups arrive beyond past the view radius.
  4. Surges and set pieces may push the crowd above the curve (never above the cap).
  5. Step it on the game’s fixed clock, not the frame’s dt, and with the same calls, or two runs from the same seed differ.
2 more in brief
  1. Set-piece times must be in order. startAt skips set pieces and surges already past, and announces the current phase again on the next update.
  2. Events are pushed each update into the array you pass: clear it after handling, and say them in words as well as with sound (the live region, a banner).
7 pitfalls in full, the hook-up guide, the module source and its tests come with the part.

Where it comes from

From another of the maker’s apps. Fully custom code.

Tommy Ettinger, mulberry32: The small seeded generator, a public-domain algorithm. The algorithm, not code.

gameaction gamewavesspawningdirectordifficulty curvepacingswarmsurvivors-likephasessurgesbossseededdeterministicheadlessno dependencies

Near it in the frame