The pack
actors
function actors(): Pack<{ actors: ActorsApi }>
The actors pack. Pure logic, so it needs no backend and runs headless.
Helpers
chips
const chips: { drift(a: Mover & { spin?: number; }, dt: number, o?: IntegrateOptions): void; seek(a: Mover, to: XY, o: SeekOptions, dt: number): void; ... 12 more ...; wander(a: Mover, speed: number, turn: number, rng: () => number, dt: number): void; } …
The chips. Each is one frame of one behaviour, mutating the mover — compose them by calling more than one, and none of them owns the actor.
createTimer
function createTimer(period: number, o: { repeat?: boolean; start?: boolean; ready?: boolean } = {}): Timer
Creates a Timer.
faceVelocity
function faceVelocity(a: Mover): void
Point a mover along its own velocity — the drifting rock, the free-flying shot.
hyperspace
function hyperspace(a: Mover, area: { x?: number; y?: number; w: number; h: number }, rng: () => number, o: { danger?: number; clear?: number; avoid?: readonly XY[]; tries?: number } = {}, ): HyperspaceResult
Jump somewhere random. danger is the chance it goes wrong, and clear keeps
a successful jump away from the things listed — a hyperspace that can drop you
on a rock is a coin flip, not a decision.
integrate
function integrate(a: Mover, dt: number, o: IntegrateOptions = {}): void
One step of plain motion. drag is per SECOND, not per frame, so the feel
does not change with the frame rate — the mistake vx *= 0.98 makes.
speedOf
function speedOf(a: Mover): number
Current speed.
splitInto
function splitInto(parent: Mover, o: { count?: number; /** Outward speed added to the inherited velocity. */ speed?: number; /** Total fan, radians. Default a full circle. */ spread?: number; /** Fraction of the parent's velocity kept. Default 1. */ inherit?: number; /** Spread the fan about this heading. Default the parent's own. */ angle?: number; rng?: () => number; } = {}): Mover[]
The split: children at the parent's position, sharing its momentum plus an even outward fan. Inheriting the parent's velocity is what makes an Asteroids split read as one rock breaking rather than two rocks appearing.
Classes
Timer
class Timer
A countdown that reports the frame it fires on. Minelayers, hatching grubs, regenerating shields, reload gates — all the same object.
period: number— The length of the countdown, in seconds.left: number— Seconds left in the current countdown.repeat: boolean— True for a timer that re-arms itself after each period.running: boolean— Off untilstart().constructor(period: number, o: { repeat?: boolean; start?: boolean; ready?: boolean } = {})update(dt: number): boolean— True on the frame it reaches zero. A repeating timer re-arms itself.get ready(): boolean— Non-destructive readiness: a period has completed and nothing has spent it. Ask as many times a frame as you like — it never advances the clock and never consumes the event, which is exactly whatupdate(dt)cannot promise. True on repeating AND one-shot timers alike.use(): boolean— Ask-AND-consume — the gate a fire button wants. True at most once per completed period, re-arming as it returns, so the cooldown lives in here rather than in the caller:if (fire.held && reload.use()) shoot();Works the same whether the timer repeats or not.get frac(): number— 0..1 through the period — a reload bar, a hatch warning.get done(): boolean— True when a one-shot timer has fired and stopped.reset(period = this.period): this— Restarts the countdown, with a new period when one is given. Returns this.stop(): this— Stops the countdown. Returns this.
Types
ActorsApi
type ActorsApi = typeof kit
game.actors — every function and type this pack carries, as one namespace.
AvoidAimOptions
interface AvoidAimOptions extends SeekOptions
Configures the avoidAim chip.
arc?: number— Half-angle of the player's "aimed at me" cone, radians. Default 0.5.retreat?: number— Acceleration away while aimed at. Defaultaccel.
HomeOptions
interface HomeOptions
Configures the home chip.
speed: number— Constant flight speed.turn: number— Radians per second it can turn. A missile that can turn instantly is not a missile.
HyperspaceResult
interface HyperspaceResult extends XY
The result of hyperspace: the landing point, and whether the jump was safe.
ok: boolean— False when the jump failed — the classic risk of the verb.
IntegrateOptions
interface IntegrateOptions
Configures integrate, and the chips that call it.
drag?: number— Fraction of velocity shed per second, 0..1. Default 0.gravity?: number— Downward acceleration (screen +y). Default 0.maxSpeed?: number— Speed ceiling. Default Infinity.
Mover
interface Mover extends XY
The minimum a chip needs. rot is optional and in screen-clockwise radians.
vx: number— Velocity on x, in units each second.vy: number— Velocity on y, in units each second.rot?: number— The facing angle, in screen-clockwise radians.
OrbitOptions
interface OrbitOptions
Configures the orbit chip.
radius: number— The distance from the centre to circle at.rate: number— Radians per second, + is clockwise on screen.pull?: number— How hard it is pulled back onto the radius. Default 2.
SeekOptions
interface SeekOptions extends IntegrateOptions
Configures the seek, flee and evade chips.
accel: number— Acceleration toward the target, units/s².standoff?: number— Stop accelerating inside this. Default 0.
XY
interface XY
A 2D point: the x and y position.
x: number— The x position.y: number— The y position.


