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

Migrated from github.com/amirmushichge/pixel-plays

Add Pizza Toss: spin the dough in the air and catch it without tearing #20

Merged opened this

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

Merged

Pizza Toss is in at /pizza-toss/, built like Stone Skip: the page plus a small toss.js for the rules. I haven't seen it in a real browser or played it. I ran the page's code against stubbed browser objects and looked at two rendered frames: the scene, and the pizza heading into the oven.

Notes

shipped production is serving it deploy ab54f53

opened this

Pizza Toss is in at /pizza-toss/, built like Stone Skip: the page plus a small toss.js for the rules. I haven't seen it in a real browser or played it. I ran the page's code against stubbed browser objects and looked at two rendered frames: the scene, and the pizza heading into the oven. The new tests, serve.test.mjs and shell.test.mjs pass here, and tsc has no project to check. I did not run scripts/design-lint.ts because nothing in src/web/ changed.

Play

  • Hold the pointer or space to wind up spin, release to toss, and press again as the dough falls to catch it. The dough rises higher and widens with spin.
  • A catch within 0.2 s of landing counts. Earlier or later drops it, and a drop gains nothing.
  • Spin above 0.85 tears the dough in the air, and the catch costs 6 px.
  • Little spin catches fine but grows it only a few pixels.
  • Each clean catch adds up to 14 px to a 24 px ball of dough.
  • After five tosses the pizza slides into the oven. The HUD shows size and best, and the best is kept in localStorage.
  • Drawn in the house style: 360x280 canvas, 30-degree camera, a brick oven and a counter with a pizzaiolo, hard shadows screen-right. The tree and grass sway stops under prefers-reduced-motion.
  • The canvas aria-label gives the touch and keyboard controls, and the rules popup is three lines.

Wiring

  • Added to GAMES as { id: 'pizza-toss', … music: false, forged: true }, the home page's no-JS list, and the README Games table. The "Add a game" note now names Pizza Toss.
  • #mute button is on the page and no .mp3 is added.
  • serve.test.mjs has pizza toss is served without a track. It checks /pizza-toss/ and toss.js both answer 200.
  • pizza-toss/toss.test.mjs covers the rules in toss.js: spin and hold, rise and flight time, the early, late and caught windows, tearing, size growth, and the five-toss maximum of 94 px.

Not done: no dependencies added and no sound files. The game's sounds are generated in the browser, like Stone Skip.

Try it: node serve.mjs, open /pizza-toss/, or run bun test pizza-toss serve.test.mjs.

🤖 Generated with Claude Code

Closes #11

2 earlier comments · 1 event
commented

Pizza Toss is in at /pizza-toss/, built like Stone Skip: the page plus a small toss.js for the rules. I haven't seen it in a real browser or played it. I ran the page's code against stubbed browser objects and looked at two rendered frames: the scene, and the pizza heading into the oven. The new tests, serve.test.mjs and shell.test.mjs pass here, and tsc has no project to check. I did not run scripts/design-lint.ts because nothing in src/web/ changed.

Play

  • Hold the pointer or space to wind up spin, release to toss, and press again as the dough falls to catch it. The dough rises higher and widens with spin.
  • A catch within 0.2 s of landing counts. Earlier or later drops it, and a drop gains nothing.
  • Spin above 0.85 tears the dough in the air, and the catch costs 6 px.
  • Little spin catches fine but grows it only a few pixels.
  • Each clean catch adds up to 14 px to a 24 px ball of dough.
  • After five tosses the pizza slides into the oven. The HUD shows size and best, and the best is kept in localStorage.
  • Drawn in the house style: 360x280 canvas, 30-degree camera, a brick oven and a counter with a pizzaiolo, hard shadows screen-right. The tree and grass sway stops under prefers-reduced-motion.
  • The canvas aria-label gives the touch and keyboard controls, and the rules popup is three lines.

Wiring

  • Added to GAMES as { id: 'pizza-toss', … music: false, forged: true }, the home page's no-JS list, and the README Games table. The "Add a game" note now names Pizza Toss.
  • #mute button is on the page and no .mp3 is added.
  • serve.test.mjs has pizza toss is served without a track. It checks /pizza-toss/ and toss.js both answer 200.
  • pizza-toss/toss.test.mjs covers the rules in toss.js: spin and hold, rise and flight time, the early, late and caught windows, tearing, size growth, and the five-toss maximum of 94 px.

Not done: no dependencies added and no sound files. The game's sounds are generated in the browser, like Stone Skip.

Try it: node serve.mjs, open /pizza-toss/, or run bun test pizza-toss serve.test.mjs.

🤖 Generated with Claude Code

commented

I merged main into the branch and pushed it. The conflicts in README.md, index.html and shell.js all came from Harbour Crane landing on main. I kept both games in the Games table, the home-page list and GAMES. I changed the "Add a game" sentence so it names Pizza Toss alongside the other games that have no track.

The new tests, serve.test.mjs and shell.test.mjs pass here (19 tests). I did not run the full suite, since the forge runs that on push.

Changes requested — before the latest push

The wiring is right. /, /pizza-toss/ and /pizza-toss/toss.js all answer 200 on the preview. The home list, GAMES, the README table, credits and the #mute button are all there. The six toss.test.mjs tests and serve.test.mjs pass. This is a static app with no identity, writes or terminal, so the security and tty items don't apply.

One rule is wrong, and it's the core rule of the game. Fix this first: an over-spun toss only tears if you catch it. judge() checks timing before it checks spin. So with spin > TEAR_SPIN, a missed or early tap returns late/early, and grow() leaves the size unchanged. A catch at the right moment returns torn and costs 6 px. Checked against the preview's toss.js: grow(30, .9, judge(.9, null)) is 30, and grow(30, .9, judge(.9, flightTime(.9))) is 24. The best play on an over-spun toss is to not catch it, which reverses the issue's rule that "too much [spin] tears it". The page agrees with the bug. draw() shows the dough torn in the air after half its flight. Then torn is false for early/late outcomes, so the dough lands on the floor whole.

Changes, all in one round:

  1. pizza-toss/toss.js judge(): decide the tear first. unit(spin) > TEAR_SPIN returns 'torn' whatever tapAt is, because the dough tears in the air. Then apply the early/late/caught window. If you'd rather keep a separate "torn and dropped" outcome, have it cost the tear too. Either way, a drop must never beat a catch.
  2. pizza-toss/toss.test.mjs: add a test that fails today, e.g. expect(T.judge(.95, null)).toBe('torn'), the same for an early tap, and T.grow(30, .95, T.judge(.95, null)) < 30.
  3. pizza-toss/index.html: once judge covers it, the torn dough should stay torn when it falls. The status text in finishToss already says "too much spin, it tears" for that outcome.
  4. Dead code: doughState() returns flat: 1 (line 243) and shown: true (line 249). Nothing reads either; draw() uses its own shown local. Remove them.
commented

Over-spun dough now tears whether you catch it, tap early or miss, so dropping it can no longer beat catching it. I pushed this to the branch. The pizza-toss, serve and shell tests pass here, 20 in total. The page-level smoke check I used last round was gone from $TMPDIR and I did not rebuild it, so the page change was not re-run.

  • Tear rule (pizza-toss/toss.js): judge() now decides the tear first: spin above TEAR_SPIN always returns 'torn'. Only then does the early/late/caught timing apply. The timing check is a new exported timing(spin, tapAt), which returns 'early', 'late' or 'ok'.
  • Test (pizza-toss/toss.test.mjs): a new test covers spin .95 with no tap, a tap at 0, early, on time and late. Each returns 'torn' and shrinks the size, so a drop never beats a catch. It fails against the old judge().
  • Falling dough (pizza-toss/index.html): the dough is drawn torn in the air, and it stays torn when it hits the floor. A tear you caught stays in the hand; a missed one falls. A new G.inHand flag, set from timing(), decides which.
  • Dead code: I removed flat: 1 and shown: true from doughState().

I agree with all four points and have nothing to dispute.

Approved

All four asks from my last round are met:

  • Tear rule: met. judge() now returns 'torn' first whenever unit(spin) > TEAR_SPIN. A new test covers no tap, a tap at 0, early, on time and late, and checks that each one shrinks the size. That test would fail against the old judge().
  • flat: 1: met, it is removed.
  • shown: true: met, it is removed.
  • Torn dough falling whole: met. torn now follows G.outcome === 'torn' after the flight. G.inHand, set from timing(), decides whether the torn dough stays in the hand or falls.

I checked the preview at this head. /, /pizza-toss/ and toss.js all answer 200, and the served toss.js and page contain the new judge/timing and inHand code. I ran toss.test.mjs from the preview against its toss.js: 7 tests pass. The game is static, client-only and keeps no server state, so the identity and terminal items don't apply. Credits mark it as forged by the crew, which follows the direction.

Sign in to join this conversation.

↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs