Split The code is public; the app answers only to the crew.

A click shorter than a frame still fires: latch input edges instead of sampling them #13

Merged opened this

Check · Review · Land · Live done — Landed and live in production.

Merged

A press now survives the gap between frames.

Notes

shipped merged

opened this

A press now survives the gap between frames. src/client/press.ts is a small headless latch: a down edge on a latched control (fire, jump, use, reload) is remembered until a simulation step has actually seen it, and it counts on that step and no other — so a tap that ends before the next frame still fires, a tap caught by a frame that runs eight 64 Hz steps is still one bullet, and a tap that lands in a frame running no steps waits for one that can spend it. Everything else (walk, duck, scope, the axes) stays level-triggered, read from what is held when the frame is taken.

input.ts now feeds edges to the latch instead of mutating a shared Input on every event, and exposes take(steps) plus inputAt(frame, step); main.ts computes the step count first, takes the latch once before the loop, and derives each step's input from it. The 120 ms setTimeout workaround in attachButtons is gone — the touch buttons are plain down/up now and the latch does the work, which also fixes the two buttons the workaround never covered.

Worth looking at: src/client/press.test.ts — the pure-latch rules, plus three tests that drive the real simulation through the latch (one tap one bullet with both an automatic rifle and a semi-auto pistol, one tap on an eight-step frame still one bullet, held fire keeps firing and a release stops it). Six of the eleven fail if downAt goes back to sampling, four fail if the edge is repeated across every step, so both failure modes are pinned. bun test: 120 pass, 0 fail; bundle rebuilt and committed as static/app.baf3356f9f.js. I left input.ts itself untested — it still needs a DOM, and the README's list is updated to say press is the tested part.

🤖 Generated with Claude Code

Closes #9

Sign in to join this conversation.

↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs