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

19 lines
1.1 KiB
Markdown
Raw Normal View History

# js/physics/state/ — agents.md
RC-375D84 S-2. Module map: `MODULES.md`; runtime model: `architecture.md`.
Installs into `P`: createGame, makeBird, activeBird.
- `createGame(levelDef)` is the ONLY constructor of a gameplay state object.
Its shape (keys `level, world, time, score, birds, blocks, enemies, events,
scorePopups, hadEnemies, camera, status, activeBird, launched, wonAt, lostAt,
stats`) is consumed by render, app and every test — extending is OK, silently
dropping a key is not.
- Block/enemy/bird records are plain objects. S-3/S-5 (RC-375D84, landed)
extended them additively: blocks carry `ang`, `angVel`, `pivoting`
(topple DOF) and birds gain the `landed` state (a live body under gravity
while another bird is in play; see step/topple). Keep further extensions
additive and keep `createGame` the single place where initial state is minted.
- `activeBird(g)` is the canonical "whose turn is it" query — input, camera and
rules all go through it; do not re-derive it elsewhere.
- Consumes: WORLD, MATERIALS, BIRD_TYPES, ENEMY_TYPES (constants) + makeBird.