The flight game pairs a two-rock field with a separate seam-distance calculator. Its readout shows the ship's position, velocity, heading, simulation time, score, and object counts. The inspector checks strict same-height overlap; its inputs do not move the ship or rocks in the game.

Use the worked example
Start the game, then use the turn buttons, Thrust pulse, and Fire. Pause to inspect the ship readout and use Step 1/60 s for one update. Separately, enter 5 and 315 in the seam inspector and press Inspect same-height distance. It reports distance 10 against a radii sum of 19.
Trace the result step by step
Use a 320 × 240 simulation field. These are simulation units expressed as pixels, independent of the displayed element's responsive size.
Heading starts at zero, pointing right. The turn buttons change heading by 15 degrees per activation. A thrust pulse adds 12 units per second to velocity along that heading; speed is capped at 180 by scaling the whole vector. This button-pulse interface keeps heading and velocity independently inspectable.
After a thrust pulse, velocity persists until another pulse changes it. Turning a moving ship does not rotate its existing velocity. For example, a rightward-moving ship turned downward continues moving right until downward thrust adds a new component. The on-screen nose and travel direction can differ.
The ship starts at (160, 120) with radius 7. R1 starts at (40, 40), radius 16, moving right at 20 units per second; R2 starts at (250, 180), radius 12, moving left at 15. The rocks do not split. Removing both wins, while a ship collision loses the single-life game. Bullet contacts are resolved across all shots by contact time, then by bullet and rock ID when times tie. A bullet and rock can each be consumed only once.
MDN's collision guide explains circle overlap using center distance and the sum of radii. Its illustrated implementation derives centers from top-left positions. Here, the records already store centers: do not add the radius again.
Wrap each center into [0, 320) horizontally and [0, 240) vertically using a modulo operation that also handles negative positions. For wrapped centers, take the smaller of the direct horizontal separation and 320 minus that separation; do the corresponding calculation with 240 vertically.
Two centers at x = 5 and x = 315, with equal y, are 10 units apart across the seam, not 310. Combine the minimum horizontal and vertical separations into the circle-distance calculation.
For a radius-7 ship and radius-12 rock, this prototype declares strict overlap: distance less than 19 is a collision. Distance 19 is touching and does not collide; distance 18 does. A bullet is a point for collision purposes, so its collision threshold is the rock's radius, regardless of any decorative bullet mark.
A bullet moving from x = 318 to wrapped x = 2 did not sweep across the middle of the screen. Preserve its continuous displacement and split the path at the seam, or compare against the appropriate periodic images of the rock. Include rock movement in relative-motion collision checks.
Choose Contact order example, then Step, for a separate accelerated-shot demonstration. Two stationary radius-10 rocks sit at x = 100 and 150 on y = 80. B1 starts at x = 50 moving at 6000 units/s; B2 starts at x = 85 moving at 2000 units/s. B2 reaches R1 at 0.0025 seconds, then B1 reaches R2 at 0.015 seconds. Both disappear for 200 points. These are labeled test-shot speeds; ordinary Fire remains at 220.
Copy a prompt for this example
Create one HTML page with an original two-rock flight game and a separate wrapped-distance inspector. Use a responsive 320 by 240 simulation field and display phase, score, rock and bullet counts, ship position, velocity, heading, and simulation time.
Start the radius-seven ship at (160,120), stationary and facing right. R1 starts at (40,40), radius sixteen, velocity (20,0); R2 at (250,180), radius twelve, velocity (-15,0). Turning changes heading by fifteen degrees per button activation. Each thrust pulse adds twelve velocity units along that heading; cap total speed at 180 without rotating existing velocity.
Point bullets travel at 220 units per second, live one simulation second, and have a quarter-second firing cooldown. A bullet removes at most one rock and earns 100 points. Gather all swept contacts, sort by time then bullet and rock ID, and skip contacts involving consumed objects. Handle relative swept bullet paths across periodic images, rather than drawing a wrapped shot through the screen center. Check ship collision before awarding a final-shot win.
Provide Start, Pause, one-sixtieth-second Step, Reset, turn, thrust, and fire buttons. Step operates while paused. Hidden-page state pauses the game.
The independent inspector accepts same-height x coordinates from zero up to 320, excluding 320. Inputs 5 and 315 have wrapped separation ten. For radii seven and twelve, overlap is strict below nineteen; touching at nineteen is excluded. Inspector inputs must not reposition game objects. Add a paused Contact order example: radius-10 stationary rocks at (100,80) and (150,80), B1 at (50,80) moving (6000,0), and B2 at (85,80) moving (2000,0). One Step resolves B2/R1 before B1/R2 for 200 points. Keep the ship away from them. Return the complete HTML with inline game code and original simple graphics.
Before changing collision code, compare the separate seam calculation with the game's movement and counts. NOS can preview the prepared HTML for that discussion. Keep a shot's path in the code review: the page draws bullets and counts them, but does not provide a per-bullet trajectory table.