Isle-Slingers/js/physics/step/agents.md

23 lines
1.4 KiB
Markdown
Raw Normal View History

# js/physics/step/ — agents.md
Part of the modularization pass. Module map: `MODULES.md`; runtime model: `architecture.md`.
Installs into `P`: step, stepPhysics, spendBird. **The physics hub.**
- `step(g, dt)` = time advance + stepPhysics + end-state check + camera. `stepPhysics`
is the integration core: gravity, air drag, bird/bird-block/bird-enemy/
block-block contacts, crush, settle bookkeeping.
- Because it reaches into nearly every unit, it is installed AFTER aim/damage and
BEFORE nothing — but all of its callees must exist in `P` by the time `step`
runs (they do, because install order is load order). Keep it that way.
- `spendBird` retires a bird that is GONE (aged out / off the island). S-5
(added 2026-09-29) split the settle branch: a bird that settles
while ANOTHER bird is in play becomes `landed` — a live body integrated
every frame in `stepPhysics` (real gravity, no lifetime timer) that falls
when its support breaks, chain-damages boards, and can kill enemies. The LAST
bird still spends (win/lose unchanged — keep it that way; the sim win/lose
test is the gate). Landed birds are cleared when the level ends (inside
`step`'s won/lost branch). `advanceToNextBird` is the shared "next bird onto
the sling" path used by both the spent and landed transitions.
- Determinism invariant: no Math.random, no Date, no DOM. Tests call this
directly at dt=1/120.