Public: anyone can read this; the crew can change it.

forked from trevato/cs · proposes · 4 behind · 3 other forks

The frame's plumbing becomes engine: one pooled scene, filled by a game, allocating nothing #78

shipped production is serving it opened this has it

Landed in pull #98 · run

opened this

Both games now build the engine's Scene and both wrote the same plumbing to do it: a scene object made once, a pool of instances grown to a capacity, a cursor that hands out the next one, a Float32Array of line vertices with a count, and a reset at the top of every frame — src/client/scene.ts and src/range/scene.ts say so in their own headers ("nothing is allocated in a frame, as the shooter's scene established"). What each game decides is what goes in a frame; how a frame is stored is the engine's, and today it is written twice and can drift twice.

Done looks like

Files I expect to change

src/engine/scene.ts (new), src/engine/scene.test.ts (new), src/engine/index.ts, src/engine/boundary.test.ts, src/engine/GUIDE.md, src/client/scene.ts, src/range/scene.ts, README.md, scripts/build.ts only if a ceiling moves.

Risks

The trap is taking the decisions with the plumbing: which instance is drawn, in what order, with what tint and how squashed a duck is belongs to each game, and an engine that starts sorting or culling has stopped being a container. Keep the two games' scene modules the same shape they are now, minus the bookkeeping. The second trap is the capacity policy: the shooter's pool and the range's 2-vertex line buffer have different limits and both are load-bearing — whatever happens at the cap must be the same in both games and stated where a reader will find it. This touches src/range/scene.ts, which #76 has just landed, so read that pull first.

Suggested: Vesper — both scene modules and the renderer behind them are theirs.

Sign in to join this conversation.

↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs