Enemy waves and survival game pacing. Hand-written early waves then generated waves from a growing threat budget, enemy types unlocked by wave, spawn groups over time, safe spawn points away from the player, caps on enemies alive, breaks between waves, boss waves, "next wave now" buttons, survival timers and endless scaling, and UI announcements. Includes a tested wave director. Use for wave-ba...
Download skill (.zip) Files on GitHubWave spawning
Drop-in: assets/waves.js (tests: scripted first wave, clear → break, boss on wave 5, budget grows, types respect minWave,
maxAlive cap, spawn points away from the player).
import { createWaveDirector, spawnPoint } from "./core/waves.js";
const waves = createWaveDirector({
enemies: { slime: { cost: 1 }, bat: { cost: 2, minWave: 3 }, brute: { cost: 5, minWave: 6, weight: 0.5 } },
scripted: [[{ type: "slime", count: 5, every: 0.8 }], [{ type: "slime", count: 8, every: 0.6 }, { type: "slime", count: 4, every: 0.3, delay: 4 }]],
budget: (w) => 4 + w * 2.5, // threat points per wave
breakTime: 4, maxAlive: 40, bossEvery: 10, boss: "king", rng: rng.next,
spawn: (type, info) => enemies.spawn(type, spawnPoint(player, arena, rng.next)),
alive: () => enemies.size,
onEvent: (e, d) => e === "waveStart" && hud.banner(d.boss ? "Boss!" : `Wave ${d.wave}`),
});
// each step: waves.update(dt) UI: waves.state.wave / .phase button: waves.skipBreak()
Pacing
- Waves 1–3 hand-written (teach each enemy alone), then generated.
- Introduce one new enemy type every few waves (
minWave), alone first, then mixed. - Breaks (3–6 s) to breathe, collect, upgrade. A “next wave now” button with a small bonus rewards confident players.
- Boss every 5–10 waves. After a boss, the next wave is easier (a dip in the curve).
- Budget growth: linear for 10–20 minute sessions; add a slow exponential for endless modes. Check with game-balance-testing.
Fairness
- Spawn off-screen or at marked spawn points, with a warning (portal, shadow, sound) 0.5–1 s before.
- Never within ~250 px of the player (
spawnPointhandles it). - Cap enemies alive (
maxAlive) for readability and frame rate; extra spawns wait. - Ranged enemies count more toward the budget than melee ones.
Survival variants
- Timer survival (“survive 10 minutes”): waves on a clock instead of on clear; budget by elapsed minutes.
- Endless: show the best wave on the title screen; seed waves for daily challenges (procedural-generation
dailySeed).