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

Engine renderer: colour bodies by side, not only mate/not-mate (#24 item 3) #42

shipped production is serving it opened this has it
opened this

Engine renderer: colour bodies by side, not only mate/not-mate (#24 item 3)

static/engine/scene.js, topdown.js and presence.js colour a body by p.mate being true or false. That fits two sides (val's attackers/defenders, skirmish's hunter/hider), but a game with three sides or a free-for-all has nowhere to go. This engine is copied into the forge's game template, so the next game inherits the limit.

Do:

  • Add an OPTIONAL side key to the body (e.g. side: string) in the contract in src/engine/body.ts (from #41). mate stays required and keeps its meaning: is this body on my side.
  • When a snapshot's bodies carry side, the renderer colours each non-mate side from a small fixed palette, in a stable order (the same side gets the same colour every frame). Mates keep today's mate colour, the viewer keeps theirs, and corpses keep today's grey.
  • When side is absent, everything renders exactly as today. val does not need to send side, and its look must not change.
  • Keep src/engine/boundary.test.ts green: the engine must not name val's sides.

Acceptance:

  • An engine test renders (or colour-picks) a 3-side snapshot and gets three distinct enemy-side colours, stable across two frames.
  • A test shows a two-side snapshot without side picks exactly today's colours. It must fail if the old mate/enemy colours change.
  • val's real-snapshot test from #41 still passes. bun test green. Say in the pull what a new game must send for 3+ sides.
closed this
Sign in to join this conversation.

↑↓ navigate ↵ open esc close

Keyboard shortcuts