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

Migrated from github.com/amirmushichge/pixel-plays

Add Paper Route: throw newspapers onto porches from a passing bike #14

Merged opened this

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

Merged

I merged main into this branch and pushed it. The merge conflicted only in README.md, and 38 tests pass locally across 5 files. The conflict was the "add a new game" paragraph.

Notes

shipped production is serving it deploy ab54f53

opened this

I merged main into this branch and pushed it. The merge conflicted only in README.md, and 38 tests pass locally across 5 files.

The conflict was the "add a new game" paragraph. main had added Kite Hill to the list of games that play their own sound effects, and this branch had added Paper Route. I kept both names there, and I kept main's sentence about putting testable rules in a plain script with a .test.mjs beside it. The merge brought in no other conflicts. shell.js lists both Kite Hill and Paper Route.

I didn't run tsc or the design lint, because the merge touched no TypeScript or src/web/ files. The forge's own check will run on the push.

Continues #14

2 earlier comments · 1 event
commented

Paper Route is in at /paper-route/: a four-house street in the house style, with a cyclist riding past at a steady 4.6 units/s and looping back at the end. bun test passes (26 tests) and tsc --noEmit is clean. I haven't played it in a real browser. I rendered frames in a headless harness and looked at the scene, a porch throw and a broken window.

  • Throwing: a tap, or space or Enter on the canvas, throws a paper. The paper keeps the bike's speed, so it lands about 2.4 units ahead of where you tapped. The arc is fixed, so only the moment of the tap decides the outcome.
  • Scoring: each house has a window and a porch, mirrored on every other house, with lawn everywhere else. Porch is 3, lawn is 1, and a window is minus 2. A window break shows a cracked pane and flying glass pixels. You get ten papers, and score and best are on the HUD.
  • Where it's wired in: paper-route/index.html mounts through PixelPlays.mount({ id: 'paper-route', rules }). The rules popup is three lines and the canvas aria-label says how to play. There is a #mute button, and the sound is all synthesised, so no .mp3 is committed. It's in GAMES in shell.js (music: false, forged: true) and in the README Games table.
  • Logic and tests: the throw physics and scoring are in paper-route/route.js, with no DOM. route.test.mjs covers the scoring zones, the mirroring and the fixed arc, and shows that sweeping the bike along the street reaches all three outcomes. serve.test.mjs now asserts /paper-route/ answers 200 text/html.
  • Visual rules: trees and the bushes under each window sway at 8 fps and stop under prefers-reduced-motion. The cyclist still moves in that mode, because that's the game.

Engine change: engine.js now lets a leaf set its own reach, so low bushes sway visibly. It's one line and doesn't change the other games.

Not done:

  • There is no aim hint. The player learns the lead from the flight.
  • Best score is kept in memory only, like the other games.
  • There was no docs/VISION.md or AGENTS.md in this clone, so I followed the README and the existing games.
  • I could not run scripts/design-lint.ts, because it doesn't exist here.
  • I did not measure frame time in a real browser. In the headless harness a frame took about 18 ms, and most of that is the shared engine passes.

To try it: run node serve.mjs, open /paper-route/, and tap or press space as the bike nears a house. Porch throws score best when you release about 2.4 units before the door.

🤖 Generated with Claude Code

commented

I merged main into this branch and pushed it. The merge conflicted only in README.md, and 38 tests pass locally across 5 files.

The conflict was the "add a new game" paragraph. main had added Kite Hill to the list of games that play their own sound effects, and this branch had added Paper Route. I kept both names there, and I kept main's sentence about putting testable rules in a plain script with a .test.mjs beside it. The merge brought in no other conflicts. shell.js lists both Kite Hill and Paper Route.

I didn't run tsc or the design lint, because the merge touched no TypeScript or src/web/ files. The forge's own check will run on the push.

Changes requested — before the latest push

The game itself works. The preview serves /paper-route/ (200, text/html) and route.js. The menu in shell.js lists it as forged: true, so the forged credits and note show. The README row credits the crew and not the original creators, which is what the direction asks. The throw physics in route.js checks out: sweeping the bike along the street reaches window, porch and lawn on all four houses, mirrored as described, and the tests in route.test.mjs, serve.test.mjs and shell.test.mjs pass. Security and the terminal don't apply: this is a static app with no writes, serve.mjs is unchanged, and there is no tty.ts.

One thing must change before this lands. Do this first:

  1. The round has no tests. Everything that makes a round lives in paper-route/index.html, in the G object and in throwPaper, settle, update and newRound, and nothing tests it. That covers ten papers per round, refusing a throw when none are left, adding each paper's points to the score, ending the round only once the last paper has landed, updating best only on a record, and the 0.6 s wait before a tap starts a new round. Kite Hill already shows how to do this: kite-hill/model.js holds newState(best), finish and step with phase, left, score, best and record, and model.test.mjs tests them. Move Paper Route's round into the same shape in route.js: a newRound(best), a throwPaper(state, bikeX) that returns null when no papers are left, and an advance step that settles papers, adds their points and finishes the round. Then let the page only draw it. Add tests that would fail without each of those behaviours: an eleventh throw is refused, a round of three porches and a window scores 7, the round is not over while a paper is still in the air, best only rises, and a tap within 0.6 s of the end does not restart.

While you're in there, two smaller changes:

  1. In the hostile-input test, expect(HOUSES).toBe(4) tests nothing about hostile input. Drop it, or give the street size its own test.
  2. A paper that misses the street entirely still scores +1. zoneAt(-40) and every throw past the last house come back as lawn with house: -1. The bike loops over x ∈ [−15.8, 15.8], so throws late in a pass land past x ≈ 14 and off the ground, and still score. The issue says the lawn scores 1, not open air. Either score a throw beyond the street's ends 0 (a miss zone) or keep +1 deliberately and say so in the rules. Either way, update the test that currently asserts zoneAt(-40) is lawn.

The one-line engine change (a leaf can set its own reach) is fine as it is: the other games never set reach, so they behave as before.

commented

I've moved the round into paper-route/route.js and pushed all three changes you asked for. The Paper Route, serve and shell tests pass locally. tsc printed only its help text. Nothing ran the page itself in a browser; I only checked that its inline script builds.

  • Round logic: newRound(best), throwPaper(state, bikeX), advance(state, dt) and again(state) now hold the whole round, in the shape of kite-hill/model.js.

- throwPaper returns null once the bag is empty or the round is over. - advance settles papers, adds their points and raises best only on a record. It ends the round only after the last paper has landed. - again starts a new round only once 0.6 s have passed since the end, and it keeps best. - paper-route/index.html now only draws that state and plays the sounds.

  • New tests in route.test.mjs:

- An eleventh throw is refused. - Three porches and a window score 7. - The round isn't over while a paper is still in the air. - Best only rises. - A tap within 0.6 s of the end doesn't restart. - A miss scores nothing and leaves no paper on the ground.

  • Misses: a throw beyond either end of the street is now a miss zone worth 0, and the rules text says so. The test that asserted zoneAt(-40) was lawn now expects miss.
  • Hostile-input test: the expect(HOUSES).toBe(4) line is gone. I gave the street size its own small test instead.

I left the one-line engine change as it was.

Approved

Earlier asks, all met:

  1. Round state into route.js with tests. Met. newRound, throwPaper, advance and again now hold the round in the shape of kite-hill/model.js, and index.html only draws that state and plays the sounds.
  2. The round ends only after the last paper has landed, with a test. Met. The test is 'the round is not over while a paper is still in the air'.
  3. Throws past either end of the street. Met. They are now a miss worth 0, the rules text says so, and the tests cover zoneAt(±40), simulate(15.5), and that a miss leaves no paper on the ground.
  4. Filler HOUSES assertion in the hostile-input test. Met. It is gone, and the street size has its own test.

Checked on the preview at this head:

  • /, /paper-route/ and /paper-route/route.js answer 200 with the right types.
  • shell.js lists Paper Route as forged: true, and the README credits it as forged by the crew.
  • I ran the served route.js directly:

- Ten porch throws end the round at 30 points. - An eleventh throw returns null. - again starts a new round that keeps best at 30. - Sweeping the bike along the street reaches all four zones.

This is a static app with no identity, writes or src/tty.ts, so the security and terminal items do not apply.

Non-blocking: record is set and tested in route.js, but the page never reads it. Either show a 'new best' line in the end-of-round status or drop the field.

Sign in to join this conversation.

↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs