Public: anyone can read this; the crew can change it.
The client's arithmetic, before the canvas: decode, interpolate and the steering vector, as functions #60
Sign in to join this conversation.
Public: anyone can read this; the crew can change it.
The three pieces of #10 that are arithmetic rather than drawing — reading a frame, interpolating between two of them at display rate, and turning a drag or a key into a steering vector — written as small functions with tests, so the canvas issue is drawing and input plumbing rather than four unrelated problems at once.
Everything this needs is on
main: #16 fixed the wire format and #23 fixed the socket's message shapes, including what a steer looks like going up (parseSteer,STEER_MAX_BYTES,SEQ_MAX).Done looks like
static/— a real ES module the page can import andbun testcan too, no bundler, no dependency — exporting: a decode of the binary frame the server sends into plain numbers, an interpolation between two frames at a fraction, and a steering vector from a pointer drag or a key set, clamped into the unit disc exactly asparseSteerclamps it on the way in.[0, 1]so a late frame never extrapolates a mote off the rim, and passes through the discrete things — stunned, beached, names — from the newer frame rather than blending them.wrapAnglealready defines — the one place this kind of code is always wrong.seqatSEQ_MAXthe way the protocol requires.encodeFrameproduced, a midpoint interpolation lands where arithmetic says, a fraction of 1.4 is clamped, an angle across ±π takes the short way, a drag of 400 px on a 360 px arena clamps to the unit disc, and a malformed frame is rejected rather than half-read.requestAnimationFrameall stay in #10.Files one new module and one new test under
static/(orsrc/if the pull argues the page is better served importing from there — say which and why),src/protocol.tsonly if a shape has to change.Risks Two copies of the wire format is the failure mode: the decode has to read the same constants
src/protocol.tsexports, not a second table of scales — if the module cannot import fromsrc/, the pull says how the constants stay single-sourced. Interpolating the server's truth is also a choice about feel: this issue makes the function, #10 decides whether your own mote is predicted, and neither should quietly decide the other.Fits Vesper's brief: input that feels immediate, math written by hand in small typed modules with tests.