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

Migrated from github.com/amirmushichge/pixel-plays

Add Archery: ten arrows at a straw target, reading the wind off a pennant #64

Merged opened this

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

Merged

Archery is added as a new game: ten arrows at a straw target across a mown meadow strip, with a pennant on a pole beside the flight line. I couldn't run it in a real browser. I drove it headlessly through a stub DOM, with mouse and keyboard, with reduced motion on and off, through a full round and a restart.

Notes

shipped production is serving it deploy ab54f53

opened this

Archery is added as a new game: ten arrows at a straw target across a mown meadow strip, with a pennant on a pole beside the flight line. I couldn't run it in a real browser. I drove it headlessly through a stub DOM, with mouse and keyboard, with reduced motion on and off, through a full round and a restart.

What changed

  • Rules, archery/range.js: plain data in and out. Drag length is power and the drag angle is aim, read on the grass: dragging down-left, straight back from the target, gives yaw 0. The sway is steady until three seconds of hold and widens after that. Flight is an arc under gravity with a wind push, scoring is gold 10, then 8, 6, 4, 2, and 0 for a miss, and the tenth arrow ends the round. The launch elevation is solved so a full draw in still air hits the gold. A draw under 20% power is let down and costs no arrow.
  • Tests: archery/range.test.mjs has 14 tests covering the cases the issue lists, plus the drag mapping and the keyboard draw. serve.test.mjs now asserts /archery/ and /archery/range.js answer 200. bun test archery serve.test.mjs shell.test.mjs passes.
  • Page, archery/index.html: 360x280 canvas, fixed camera, hard shadows screen-right, and a #mute button with no .mp3. The HUD shows score, arrow n/10, wind direction and strength, and best (kept in localStorage). The aim preview is a dotted no-wind line with the sway included, so the wind and the hold are what the player has to handle.
  • Input: mouse and touch drag from anywhere on the canvas, or arrows to aim, hold Space to draw and release to shoot. The aria-label says how to play, and the rules popup is four lines.
  • Ambient motion: only the grass and the pennant. Both stop under reduced motion, and the grass keeps its lean toward the wind.
  • Wiring: shell.js GAMES, the root index.html <li>, the README Games table and the README no-music list are all updated. bun scripts/og.mjs was run, giving og/archery.png, its share tags and a new og/home.png.

Choices and trade-offs

  • Downrange runs toward the screen's upper right, because the camera sees a target's face only if it faces the viewer.
  • Elevation isn't a separate control. Power sets speed, so a lighter draw drops lower, and yaw comes from the drag angle. The preview line makes lateral aim exact.
  • Flights run at half speed so the drift can be read.
  • The sway still applies under reduced motion, because it is a rule rather than decoration.
  • I did not add the playability tests from #42, since they hadn't landed on main.
  • The README no-music list now includes Archery but still omits Ice Fishing; I left that alone.

To try it bun run src/server.ts isn't how this repo runs; see forge.json. Open /archery/ on the preview. Drag down-left from anywhere on the canvas, watch the pennant, and release.

🤖 Generated with Claude Code

Closes #56

3 earlier comments · 2 events
commented

Archery is added as a new game: ten arrows at a straw target across a mown meadow strip, with a pennant on a pole beside the flight line. I couldn't run it in a real browser. I drove it headlessly through a stub DOM, with mouse and keyboard, with reduced motion on and off, through a full round and a restart.

What changed

  • Rules, archery/range.js: plain data in and out. Drag length is power and the drag angle is aim, read on the grass: dragging down-left, straight back from the target, gives yaw 0. The sway is steady until three seconds of hold and widens after that. Flight is an arc under gravity with a wind push, scoring is gold 10, then 8, 6, 4, 2, and 0 for a miss, and the tenth arrow ends the round. The launch elevation is solved so a full draw in still air hits the gold. A draw under 20% power is let down and costs no arrow.
  • Tests: archery/range.test.mjs has 14 tests covering the cases the issue lists, plus the drag mapping and the keyboard draw. serve.test.mjs now asserts /archery/ and /archery/range.js answer 200. bun test archery serve.test.mjs shell.test.mjs passes.
  • Page, archery/index.html: 360x280 canvas, fixed camera, hard shadows screen-right, and a #mute button with no .mp3. The HUD shows score, arrow n/10, wind direction and strength, and best (kept in localStorage). The aim preview is a dotted no-wind line with the sway included, so the wind and the hold are what the player has to handle.
  • Input: mouse and touch drag from anywhere on the canvas, or arrows to aim, hold Space to draw and release to shoot. The aria-label says how to play, and the rules popup is four lines.
  • Ambient motion: only the grass and the pennant. Both stop under reduced motion, and the grass keeps its lean toward the wind.
  • Wiring: shell.js GAMES, the root index.html <li>, the README Games table and the README no-music list are all updated. bun scripts/og.mjs was run, giving og/archery.png, its share tags and a new og/home.png.

Choices and trade-offs

  • Downrange runs toward the screen's upper right, because the camera sees a target's face only if it faces the viewer.
  • Elevation isn't a separate control. Power sets speed, so a lighter draw drops lower, and yaw comes from the drag angle. The preview line makes lateral aim exact.
  • Flights run at half speed so the drift can be read.
  • The sway still applies under reduced motion, because it is a rule rather than decoration.
  • I did not add the playability tests from #42, since they hadn't landed on main.
  • The README no-music list now includes Archery but still omits Ice Fishing; I left that alone.

To try it bun run src/server.ts isn't how this repo runs; see forge.json. Open /archery/ on the preview. Drag down-left from anywhere on the canvas, watch the pennant, and release.

🤖 Generated with Claude Code

commented

I merged main into the Archery branch, resolved both conflicts, and pushed (8de5f9c). I ran serve.test.mjs only, not the full suite, and it passes: 37 tests, 0 failures. bun x tsc --noEmit printed only its usage text, so I don't count it as a type check.

  • README.md: both sides had edited the sentence listing games that play on their own sound effects. I kept main's version, which adds Ice Fishing and Tightrope, and added Archery to it.
  • og/home.png: I didn't pick either side's binary. I regenerated it with bun scripts/og.mjs, so it is the grid of all the cards, Tightrope and Archery included, and serve.test.mjs confirms it matches.

I didn't try the preview.

Changes requested — before the latest push

Most of it is right. The rules are plain data in archery/range.js, the 14 rule tests pass, and the wiring (GAMES, the home <li>, the README table and no-music list, the og card) matches the issue. The preview serves /archery/ with the security headers. The playability tests from #49 are on main now, and Archery passes all four. A full round played through playtest.mjs works: the score counts up, the HUD shows arrow n/10, wind and best, the best is saved to localStorage, a tap restarts, the keyboard draw shoots, and a light drag says drawn too lightly · no arrow used. There is no src/tty.ts and no server-side state in this static games site, so the terminal door does not apply.

Fix first: the wind barely changes the score, and the issue says reading the wind is what makes this game its own. I fired 5,000 full-draw arrows at yaw 0 with R.newWind(), ignoring the wind completely. They averaged 8.26 points per arrow (about 83/100), and none missed the face (gold 2277, 8 1455, 6 902, 4 366). In the preview harness, dragging straight back ten times with no wind correction scored 80 and set a new best. The cause is that WIND_PUSH = 1.3 over a flight of about 0.6 s gives at most about 1.5 units of drift, while the target radius is 2.0. On top of that, the dotted still-air preview line exactly solves the aim and the drop, so the only skill left is the wind, and the wind hardly counts. Retune it, by raising WIND_PUSH, the flight time, or both, so that a strong crosswind ignored misses the face, and a fresh one ignored costs at least two rings. Then pin it down with tests:

  • In range.test.mjs, add a test that landing(1, 0, {angle: PI/2, speed: WIND_MAX}) scores 0, and that aiming into that wind (some yaw < 0) brings it back to 8 or 10.
  • Add a seeded statistical test that full-draw, yaw-0 arrows over many newWind() draws average well under 10, for example under 6.

The current test only asserts a drift of more than 0.5, so it passes with a wind that does not matter.

Second: the page-level behaviour has no test of its own. The generic playtests only check that input changes something. Add an archery test that uses playtest.mjs's boot('archery'). Check that a down-left drag fires an arrow and the HUD moves to arrow 2/10, that a drag under MIN_POWER shows no arrow used and keeps arrow 1/10, that ten shots end the round with new best and write pixel-plays-archery-best to g.store, that a tap after that restarts at arrow 1/10 · best N, and that holding Space and letting go shoots. Each of these would fail if its wiring in index.html broke, and today nothing would catch that.

Third: the pull description is stale. It says the #42 playability tests had not landed; they have (8c0d92c), and the game passes them, so say that. Drop the line about bun run src/server.ts, which this repo does not have. Note the retuned wind numbers in the description too.

commented

Archery now punishes ignoring the wind, and the page behaviour has its own tests. The archery tests pass, including the four generic playtests from #49. I didn't wait for the full serve.test.mjs run to finish this time. The forge's check runs everything on the push.

Wind retune (archery/range.js)

  • WIND_PUSH went from 1.3 to 3. I left the flight time alone.
  • Ignoring the wind with full-draw, yaw-0 arrows over 5,000 seeded newWind() draws now averages 5.27 points per arrow, and 21% miss the face. Before, it averaged 8.26 and nothing missed.
  • A WIND_MAX crosswind ignored scores 0. Aiming about 0.16–0.17 rad into it (yaw −0.18 to −0.15) scores gold, and it scores 8 anywhere from about −0.20 to −0.13, which is inside the ±0.45 yaw limit. A speed-3 breeze ignored scores 2.
  • The change also stretches headwinds and tailwinds, so those shift where the arrow lands vertically more than before. A full-draw arrow into a 6 headwind still scores 8.

Wind tests (archery/range.test.mjs)

  • The drift test now requires more than 1.5 units, not 0.5.
  • A new test checks that the WIND_MAX crosswind, ignored from either side, scores 0, and that some yaw into it scores 8 or more. It also checks that a speed-3 breeze ignored costs at least two rings.
  • A seeded test of 3,000 newWind() draws at yaw 0 requires a mean under 6.

Page tests (archery/page.test.mjs, new, uses boot('archery'))

  • A down-left drag fires an arrow and the HUD moves to arrow 2/10.
  • A drag under MIN_POWER shows no arrow used and stays at arrow 1/10.
  • Ten shots end the round with new best and write pixel-plays-archery-best to g.store. A tap after that restarts at arrow 1/10 · best N.
  • Holding Space and letting go shoots.

The flight runs in slow motion at TIME_SCALE = .5, so these tests run about 3 seconds per shot.

Pull description, replacing the old one

  • The #42 playability tests landed on main in 8c0d92c, and Archery passes all four.
  • The bun run src/server.ts line is dropped, because this repo has no server.
  • To try it, serve the folder statically or open the preview at /archery/. Drag down-left to draw straight back, read the pennant, and aim into the wind.
Approved — before the latest push

All three asks from the last round are met.

  • Wind tuning (range.js:18): met. WIND_PUSH is now 3. I ran 5,000 seeded newWind() arrows at full draw and yaw 0 against the head's range.js. They averaged 5.27 points, and 21% missed the face. A WIND_MAX crosswind ignored scores 0, and aiming about 0.165 rad into it scores 10.
  • Wind tests (range.test.mjs): met. Each of these would fail at the old tuning:

- the gale test checks that ignoring it scores 0 from either side and that some yaw into it scores 8 or more; - a speed-3 breeze ignored must score 6 or less; - the seeded mean over 3,000 winds must stay under 6.

  • Page tests (page.test.mjs): met. A playtest built on boot('archery') covers the HUD arrow count, the no arrow used let-down, ten shots to new best, the saved pixel-plays-archery-best, the restart tap to arrow 1/10 · best N, and the Space draw.

Verified: the head's archery files came from the preview, with the forge toolbar <script> line stripped, laid on main. bun test archery gives 20 pass, 0 fail, and the four generic playtests in playtest.test.mjs -t archery pass. On the preview, / lists Archery as Sport · Drag and links archery/. /archery/ loads range.js, and og/archery.png is served.

Non-blocking: a 6-speed tailwind still lands in the gold and a headwind costs one ring, so the downrange wind matters much less than the crosswind. A small range-only follow-up could fix that if play shows it.

commented

I merged main into the branch and pushed it, so the pull should merge cleanly again. The two test runs I made passed. I did not run bun x tsc --noEmit to a pass: it only printed its usage text, so it checked nothing.

  • Conflicts: main added Tram Line, and each conflict was Tram Line's entry against Archery's, so I kept both.

- README.md: both games are in the table, and the music-less list now reads "Tightrope, Tram Line and Archery". - index.html and shell.js: both games are listed. - og/home.png: regenerated with bun scripts/og.mjs, so the home card shows both games.

  • Tests: a full bun test was started but I never read its result. Before that I ran serve.test.mjs, the archery tests and the tram-line tests. All 72 passed.
Approved

Since my approval at dd8e41fe, the only change is a merge of main, which brought in Tram Line. The archery code I already passed is untouched, and every earlier ask is still met: the wind retune with its gale, breeze and seeded-mean tests, the page tests on boot('archery'), and the refreshed pull description.

The merge resolution is right:

  • shell.js GAMES and the home index.html list Archery and then Tram Line, and the no-JS fallback is still in sync, so serve.test.mjs passes with 38 tests.
  • The README table has both rows, and the no-music sentence reads "…Tightrope, Tram Line and Archery".
  • og/home.png was regenerated and matches the cards.

How I checked: I took the head's files from the preview, stripped the forge toolbar <script> and laid them on main at cf817a1.

  • bun test archery: 20 pass, 0 fail.
  • playtest.test.mjs -t archery: 4 pass.
  • serve.test.mjs: 38 pass.

On the preview, /archery/ answers 200 with nosniff and Referrer-Policy, and og/archery.png is served. No server, terminal or state is touched; this is a static game.

Non-blocking, carried over: a downrange wind still matters much less than a crosswind.

Sign in to join this conversation.

↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs