Spawn — target lifecycle and pooling

spawn creates, recycles, and despawns targets without allocation churn — bullets, enemies, particles. A pool of reusable targets: spawn borrows one, despawn returns it, and the registry stays bounded no matter how many things come and go. The unglamorous sibling every shooter needs.

Status: design. Not built yet.


What it is

Games make and destroy short-lived targets constantly — a bullet a frame, waves of enemies. Naively that churns allocation and grows the registry without limit. spawn is the lifecycle manager: pre-allocated pools of a kind, from which spawn hands out a ready target and to which despawn returns it. No per-object allocation in the hot loop, no unbounded growth.

Pools

Target lifecycle

A pool is a fixed set of one kind (bullets, sparks), created up front. spawn(pool) marks one live and hands it back; despawn(target) resets it and returns it to the pool. Over capacity, the policy is yours — recycle the oldest, or refuse the spawn — so a runaway never blows memory.

Despawn triggers

Death is usually driven by other siblings: a lifetime elapses, a target leaves the camera bounds, a collision enter fires, a state machine reaches "dead." spawn gives them one clean call — despawn — that removes the target from motion, tween, collision, and the registry together, so nothing is left holding a dead reference.

On the stage

spawn owns the registry's lifecycle: a spawned target is instantly visible to every sibling, a despawned one instantly gone from all of them. Reuse order is fixed, so pooling adds no allocation-timing nondeterminism — a pooled scene replays exactly like a freshly-allocated one.

Clients

  • Luau — require("spawn"): make pools, spawn, despawn, query counts.
  • AntBASIC — SPAWN/DESPAWN verbs over named pools for a first shoot-'em-up.

Related

Important: The Ant64 family of home computers are at early design/prototype stage, everything you see here is subject to change.