# Missile dogfight ## What this builds A top-down dogfight in the browser. Each ship turns, thrusts, and fires a short-lived shot. A hit costs a life and respawns the ship after a delay. The simulation is authoritative on a server that, in tests, runs in-process with two local clients and no network. Packets are tiny and documented so a later real socket can carry the same messages. This is an original game with its own feel, not a copy of someone else's arena. Read `spekkr.inputs.json` first. `arena` is the square playfield. `lives` is the starting count. `wrap` is whether edges wrap. `tick` is the simulation rate. `friendly_fire` is reserved and has no effect in this version. ## Out of scope - A persistent account, ranking, or chat. - Real network play in the acceptance checks; those use two in-process clients. - Teams. `friendly_fire` is unused until a later version. ## Requirements Each requirement has an id. Checks name the id they cover. ### R1. Movement - A ship has position, heading, and velocity. Thrust adds 180 units/s² along heading, capped at 260 units/s. Turn rate is 180 degrees/s. - If `wrap` is on, positions are modulo `arena`. If off, edges are walls and velocity into a wall is zeroed on that axis. - The step is 1/`tick` seconds. The same inputs produce the same positions. Accept when: the movement fixtures in `design.md` reach the documented positions at both tick rates, within 0.5 px. ### R2. Shots and hits - A shot starts 20 px ahead of the nose, travels 420 units/s, and lives 0.7 s. Radius is 3 px. A ship is a 16 px radius. - Hit detection is lag-independent: it is run on the server with the authoritative positions, as a swept circle test against the ship's circle for that step. - A shot that hits is removed. A ship that is hit loses one life and becomes invulnerable for 1.5 s during respawn. Accept when: the hit fixtures register a hit and a near-miss as in the table, at both tick rates, without any clock delay between the two clients. ### R3. Scoring and respawn - The firer of a hitting shot gains one point. The hit ship loses a life and, 1.5 s later, spawns at a documented pad with velocity 0. - A ship at 0 lives is out. The round ends when one ship remains, or at 90 s, and the higher score wins; a tie is a tie. - Respawn pads are the four corners, inset 80 px, chosen cyclically. Accept when: a scripted two-client round produces the score, lives, and spawn positions in `design.md`. ### R4. Two-client fixture - Tests start an in-process server and two clients. Each client sends input for a listed step. The server broadcasts state. - No UDP, WebSocket, or wall clock is required. A virtual clock advances one tick at a time. Accept when: the scripted mid-fight, hit, and respawn moments can be screenshotted from the server state and match the goldens. ### R5. Files - One command runs movement, hit, and two-client tests, and writes the four screenshots. Accept when: the command passes at tick 30 and tick 60 from a clean folder. ## Verification Local two-client tests, with an in-process server and a virtual clock, cover movement, shots, scoring and respawn. Hit detection is a lag-independent swept test and is checked at both tick rates. No live network is required. Four golden frames are taken from the scripted round. ## Definition of done - Every acceptance check above runs from one command, and all pass at the person's inputs. - A README says how to run a local fight, how to run the checks, and what a later socket must carry.