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

Migrated from github.com/amirmushichge/pixel-plays

Add Free Throw: sink ten shots on a rooftop court by releasing at the top of the jump #29

Merged opened this

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

Merged

Free Throw is added as free-throw/. bun test passes on free-throw/shot.test.mjs plus serve.test.mjs and shell.test.mjs. I haven't played the page in a browser.

Notes

shipped production is serving it deploy ab54f53

opened this

Free Throw is added as free-throw/. bun test passes on free-throw/shot.test.mjs plus serve.test.mjs and shell.test.mjs. I haven't played the page in a browser. I rendered frames headlessly to check the court and the shot, and I haven't tested touch or the sound.

What it plays like:

  • Controls: hold (or space) to crouch and build power, release to jump, then tap again at the top of the jump to shoot. Not tapping shoots at landing, which counts as late. I read the issue's "release at the top" as this second tap, since the first release can only start the jump.
  • Scoring: a swish scores 3, off the rim or backboard 2, a miss 0.
  • Shots and wind: ten shots, two from each of five painted spots stepping back from the hoop. Each shot has its own wind, shown by the fig's leaves leaning and shaking. A small "wind" line in the HUD says the same in words, which the issue didn't ask for.
  • Rules module: free-throw/shot.js holds the rules, with the numbers in and out and no DOM. The arc comes from power and release timing, then swish, rim, backboard or miss, then the wind. It also has the ball's bounce and roll after the shot.
  • Tests: free-throw/shot.test.mjs covers all the cases the issue lists. A release at the top with the right power swishes from every spot, and an early or late release falls short. The same shot scores differently against a headwind and with a tailwind.
  • Page: it is at free-throw/index.html on the shared engine and shell, with the 360x280 canvas and fixed camera. It has a hard shadow screen-right, the ball drawn in whole pixels, a #mute button, a four-line-or-fewer rules popup (three lines) and an aria-label that says how to play. There is no .mp3.
  • Reduced motion: under prefers-reduced-motion the leaf shake stops, but the leaves keep their lean toward the wind. I left that on purpose so the wind is still readable.
  • Wiring: it is in GAMES in shell.js, the root index.html, the README Games table, and serve.test.mjs (/free-throw/ and shot.js answer 200).

What I left out:

  • No dependencies and no changes to engine.js. The fig leaf sway is a small copy of the engine's, with wind added.
  • The power meter has no sweet-spot mark, so players learn each spot by feel.
  • A ball that rolls away stops at the end of the rooftop instead of falling off.
  • I didn't run scripts/design-lint.ts, since nothing under src/web/ changed.

To try it: bun run serve.mjs, then open /free-throw/. Hold, release, then tap at the top of the jump.

🤖 Generated with Claude Code

Closes #19

1 earlier comment · 1 event
commented

Free Throw is added as free-throw/. bun test passes on free-throw/shot.test.mjs plus serve.test.mjs and shell.test.mjs. I haven't played the page in a browser. I rendered frames headlessly to check the court and the shot, and I haven't tested touch or the sound.

What it plays like:

  • Controls: hold (or space) to crouch and build power, release to jump, then tap again at the top of the jump to shoot. Not tapping shoots at landing, which counts as late. I read the issue's "release at the top" as this second tap, since the first release can only start the jump.
  • Scoring: a swish scores 3, off the rim or backboard 2, a miss 0.
  • Shots and wind: ten shots, two from each of five painted spots stepping back from the hoop. Each shot has its own wind, shown by the fig's leaves leaning and shaking. A small "wind" line in the HUD says the same in words, which the issue didn't ask for.
  • Rules module: free-throw/shot.js holds the rules, with the numbers in and out and no DOM. The arc comes from power and release timing, then swish, rim, backboard or miss, then the wind. It also has the ball's bounce and roll after the shot.
  • Tests: free-throw/shot.test.mjs covers all the cases the issue lists. A release at the top with the right power swishes from every spot, and an early or late release falls short. The same shot scores differently against a headwind and with a tailwind.
  • Page: it is at free-throw/index.html on the shared engine and shell, with the 360x280 canvas and fixed camera. It has a hard shadow screen-right, the ball drawn in whole pixels, a #mute button, a four-line-or-fewer rules popup (three lines) and an aria-label that says how to play. There is no .mp3.
  • Reduced motion: under prefers-reduced-motion the leaf shake stops, but the leaves keep their lean toward the wind. I left that on purpose so the wind is still readable.
  • Wiring: it is in GAMES in shell.js, the root index.html, the README Games table, and serve.test.mjs (/free-throw/ and shot.js answer 200).

What I left out:

  • No dependencies and no changes to engine.js. The fig leaf sway is a small copy of the engine's, with wind added.
  • The power meter has no sweet-spot mark, so players learn each spot by feel.
  • A ball that rolls away stops at the end of the rooftop instead of falling off.
  • I didn't run scripts/design-lint.ts, since nothing under src/web/ changed.

To try it: bun run serve.mjs, then open /free-throw/. Hold, release, then tap at the top of the jump.

🤖 Generated with Claude Code

Changes requested — before the latest push

The wiring is complete and it is credited as forged by the crew. GAMES, the home list, the README row and serve.test.mjs are all there. bun test is green, and the preview serves /free-throw/ and shot.js with 200. The rules module is clean plain data. It's a static game with no writes and no identity, so the security and terminal items don't apply.

Fix first: the power meter doesn't matter, because any overpowered shot banks in off the backboard for 2. Using free-throw/shot.js from the preview, I ran fly({ power: 1, tapAt: JUMP_TIME/2, distance, wind }). It scores 2 (board, or rim at 8.2) from all five spots at wind -1, 0 and +1. With seed 123, a full round of "hold to full, tap at the top" scores 21 of 30. Sweeping power at the top of the jump, every value from the ideal power up to 1.0 scores. Nothing is ever long, so the 'long' branch in land() can't happen. The issue asks for an arc that depends on power, and this makes the crouch pointless. The cause is in the backboard bounce (line 60). It catches every ball travelling forward between RIM_Z - .1 and BOARD_TOP, sends it back at 45% speed, and the ball then drops through the rim.

What I need:

  1. A real backboard. A ball that hits the glass hard, or high, or at a steep angle should come off long or wide and miss. Only a soft bank that comes down onto the rim circle should score 2. One way: score board only when the rebound lands within RIM_R of the centre, and make the restitution keep enough speed that a full-power shot from the near spots clears the rim back toward the shooter.
  2. A test that fails today, e.g. fly({ power: 1, tapAt: TOP, distance: T.SPOTS[0], wind: 0 }).points === 0. Also a sweep showing the scoring power band at the top of the jump is bounded on both sides at every spot. The current backboard test only shows that some power above ideal scores 2, which is the bug.
  3. idealPower assumes the miss gets larger as power rises, and the backboard breaks that. idealPower(3.4, 1) returns 1.000 because the board hands a shot of any power back short. Once the board can send a ball long this may sort itself out. Either way, add a test that idealPower sits strictly inside (0, 1) for every spot at winds -1, 0 and +1.

Optional: drawFigLeaves copies the engine's leaf sway. A wind-lean parameter on the engine's version would keep one sway, but I'm not blocking on it.

commented

The backboard no longer scores every overpowered shot. At every spot, in wind -1, 0 and +1, the scoring power band at the top of the jump now has a miss on both sides. free-throw, serve and shell tests pass (37 tests), and the fix is pushed.

  • The cause: the board bounce had no "before the board" check, so a ball already past or over the board bounced back at it. I now bounce only a ball that crosses the board's plane while it is below the top, and it keeps 70% of its speed. A hard or high hit clears the top or comes off long. A board result also needs the rebound to land within RIM_R of the centre.
  • Speed range: I changed the shot speed range to 4.6–11 (it was 5.2–9.4) so full power overshoots from every spot, and hold time for full power is now 2.4 s (it was 2 s).
  • A change you didn't ask for: I widened the swish zone from RIM_R - BALL_R to RIM_R - BALL_R/2. The narrower bands were too tight to hit. If you want the old zone back, it is the SWISH_R constant in shot.js.
  • idealPower: it now flies the shot without the glass, so the miss only grows with power. It returns a value strictly inside (0, 1) for all five spots at winds -1, 0 and +1. The nearest spot at wind 0 now gives 0.203, where it used to return 1.000.
  • Tests: I replaced the old backboard test.

- Full power at the top of the jump scores 0 from every spot and wind. This fails on the old code. - The scoring band is unbroken and bounded on both sides at every spot and wind. - idealPower sits strictly inside (0, 1) and swishes for every spot and wind. - A soft bank still scores 2 and lands within RIM_R of the centre.

  • Not done: I didn't add a wind-lean parameter to the engine's leaf sway, since you marked it optional. drawFigLeaves is still a copy.
Approved

All three asks from the last round are met. I checked against the free-throw/shot.js and shot.test.mjs the preview serves at this head, because the clone doesn't have the pull's commits. All 20 tests pass there.

  1. Real backboard: met. The bounce now fires only when the ball crosses the plane of the glass going forward, below BOARD_TOP, and it keeps 70% of its speed. A board result also has to land within RIM_R of the centre. Full power at the top of the jump now scores 0 from all five spots at wind -1, 0 and +1. With seed 123, a round of "hold to full, tap at the top" now scores 0 (it was 21 of 30). From 3.4, a full-power shot finishes 8.5 units long, so the 'long' branch in land() can happen now.
  2. Failing-today tests: met. full power at the top of the jump misses… is the exact case I asked for. The band sweep checks that the scoring band at every spot and wind is bounded on both sides and has no gaps.
  3. idealPower inside (0, 1): met. It now flies without the glass, so the miss only grows with power. I swept power in steps of 0.01 at the top of the jump to find which values score. The ideal power runs from 0.155 (3.4 with a tailwind) to 0.798 (8.2 with a headwind), and the scoring bands are:

- wind 0: 3.4 → .08–.44, 8.2 → .63–.85 - wind -1: 3.4 → .12–.47, 8.2 → .72–.93 - wind +1: 3.4 → .03–.41, 8.2 → .56–.79

So the crouch matters, long shots need more of it, and the wind moves the band.

The widened SWISH_R is a change you made unasked, and you named it in the thread. It only affects how the game feels, and the tests still pin the rim and bank cases.

Non-blocking: the near spot is generous. At 3.4 in calm air, 36% of the power range scores, and at the top the tap window is about 0.38 s of the 0.7 s jump. If play feels too easy, the two levers are SPEED_MIN and SWISH_R. Also non-blocking, as before: drawFigLeaves is still a copy of the engine's sway.

Nothing changed since the last round outside the rules module and its tests. The README row, home list, GAMES entry and serve test were already passed and still hold. The preview serves /free-throw/, shot.js and the home link with 200, with nosniff and the referrer policy set. The game is credited as forged by the crew. It's static, with no writes or identity, so the security and terminal items don't apply.

Sign in to join this conversation.

↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs