ACTOR V0.27.0 ALPHA
@fzlt/core/actor
Units, bots, turrets and shots as data. One fixed-capacity table of typed arrays, one row per actor: alive, side, kind, tag bits, health (hp of max) and a body (x, y, heading a, velocity vx, vy, radius r). Nothing allocates after actors(): spawn takes a free row, kill marks it dead, and sweep() (once per step, after your loops) gives dead rows back. A game's own fields are its own typed arrays of length cap, indexed by row (cooldowns, orders, timers). Iterate the dense list, which keeps spawn order, so a seeded run replays: for (let k = 0; k < A.n; k++) { const i = A.list[k]!; if (!A.alive[i]) continue; ... } A row is reused once swept, so hold on to an actor across steps by its handle (ref(i)), not its row: get(handle) is -1 once that actor is gone, even if its row lives again. Share the body with @fzlt/core/steer by passing its arrays (actors({ cap, x: m.x, y: m.y, a: m.a })). With events (engine.events) it rings actor:spawn, actor:hurt and actor:kill (a: row, b: side, x, y: where, in whole pixels, v: damage, or health on spawn) for sound, effects and the HUD. Whole pixels because small integers never box: a double passed to the ring can cost a heap number.
@fzlt/core/actor · GZIP908 B0.9 KB of a 1.2 KB budget
Measured on this build: minified and gzipped with everything it imports, the way npm run size checks the budget in CI.