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

Migrated from github.com/amirmushichge/pixel-plays

Add Tram Line: drive a city tram and stop each door on the yellow mark #63

Merged opened this

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

Merged

Tram Line is added at /tram-line/, mounted like the other forged games. bun test passes on tram-line, serve.test.mjs and shell.test.mjs (54 tests). I haven't played it in a browser, so touch and keyboard input is untested.

Notes

shipped production is serving it deploy ab54f53

opened this

Tram Line is added at /tram-line/, mounted like the other forged games. bun test passes on tram-line, serve.test.mjs and shell.test.mjs (54 tests). I haven't played it in a browser, so touch and keyboard input is untested. A scripted driver played one full round in the vm without errors. bun x tsc --noEmit only printed its usage text (there's no tsconfig), and scripts/design-lint.ts doesn't exist in this clone, so neither check ran.

What changed

  • Rules: tram-line/line.js holds all of them with plain data in and out. line.test.mjs covers the cases you listed (coasting, braking from top speed, a 0.3 m stop scoring 3, 1.5 m scoring 1, overshoot, the eighth stop with time bonus), plus the stray-stop penalty and the round end.
  • Page: tram-line/index.html shows the HUD with score, stop n/8, km/h, seconds left and best.

- Controls: Up/W powers, Down/S brakes. On touch, the right half powers and the left half brakes. - Scene: 360×280 canvas, fixed camera, hard shadows screen-right. Waiting passengers shifting their weight is the only ambient motion, and it stops under prefers-reduced-motion. - Mute: there is a #mute button and no .mp3.

  • Registration: the GAMES entry in shell.js, the root index.html <li>, the README Games table and music-less list, and an og/tram-line.png made by bun scripts/og.mjs. serve.test.mjs now checks /tram-line/ and /tram-line/line.js answer 200.
  • Rules chosen where the issue was silent:

- Stops are 70 m apart, the first at 28 m so a mark is on screen at the start. Top speed is 10 m/s, braking takes 14.3 m from top speed, and the view shows about 29 m ahead. - A stop counts after the tram is still for 0.4 s within 2 m short of the mark or the 3 m shelter. Stopping in that zone but more than 2 m off scores 0 and loses no one. - Passing the shelter end at speed is an overshoot: 0 points, and that stop's 2–5 passengers are counted as lost and shown waving. Lost passengers are only counted and shown, with no score penalty, since the issue didn't ask for one. - The tram is held for 1.2 s at a stop. A stray stop is 1 point, taken once per halt, and the score never goes below 0. - The 3-point mark is painted on the kerb, with a tall yellow stop sign and the yellow door frame as aids. Ticks at 10, 20 and 30 m out show the braking distance.

  • Performance: the tram and each shelter are drawn once, then moved in whole pixels, and the ground has 8 pre-drawn scroll phases. A frame costs about 4 ms in the vm, down from about 76 ms when I drew everything live.

Left out

  • No engine sound. A scripted driver that brakes cautiously scored 1 at every stop and finished at 113 s, so 120 s is tight for a careful player. A stricter driver may need a longer timetable.
  • The README Visual rules line about ambient motion now says "only where the scene names it", since passengers aren't plants.
  • Not checked: #42's playability tests (not on main here).

Try it Run bun serve.mjs and open /tram-line/. Hold Up or the right half to power, release to coast, and brake early. The ticks show the distance from the mark.

🤖 Generated with Claude Code

Closes #55

2 earlier comments · 2 events
commented

Tram Line is added at /tram-line/, mounted like the other forged games. bun test passes on tram-line, serve.test.mjs and shell.test.mjs (54 tests). I haven't played it in a browser, so touch and keyboard input is untested. A scripted driver played one full round in the vm without errors. bun x tsc --noEmit only printed its usage text (there's no tsconfig), and scripts/design-lint.ts doesn't exist in this clone, so neither check ran.

What changed

  • Rules: tram-line/line.js holds all of them with plain data in and out. line.test.mjs covers the cases you listed (coasting, braking from top speed, a 0.3 m stop scoring 3, 1.5 m scoring 1, overshoot, the eighth stop with time bonus), plus the stray-stop penalty and the round end.
  • Page: tram-line/index.html shows the HUD with score, stop n/8, km/h, seconds left and best.

- Controls: Up/W powers, Down/S brakes. On touch, the right half powers and the left half brakes. - Scene: 360×280 canvas, fixed camera, hard shadows screen-right. Waiting passengers shifting their weight is the only ambient motion, and it stops under prefers-reduced-motion. - Mute: there is a #mute button and no .mp3.

  • Registration: the GAMES entry in shell.js, the root index.html <li>, the README Games table and music-less list, and an og/tram-line.png made by bun scripts/og.mjs. serve.test.mjs now checks /tram-line/ and /tram-line/line.js answer 200.
  • Rules chosen where the issue was silent:

- Stops are 70 m apart, the first at 28 m so a mark is on screen at the start. Top speed is 10 m/s, braking takes 14.3 m from top speed, and the view shows about 29 m ahead. - A stop counts after the tram is still for 0.4 s within 2 m short of the mark or the 3 m shelter. Stopping in that zone but more than 2 m off scores 0 and loses no one. - Passing the shelter end at speed is an overshoot: 0 points, and that stop's 2–5 passengers are counted as lost and shown waving. Lost passengers are only counted and shown, with no score penalty, since the issue didn't ask for one. - The tram is held for 1.2 s at a stop. A stray stop is 1 point, taken once per halt, and the score never goes below 0. - The 3-point mark is painted on the kerb, with a tall yellow stop sign and the yellow door frame as aids. Ticks at 10, 20 and 30 m out show the braking distance.

  • Performance: the tram and each shelter are drawn once, then moved in whole pixels, and the ground has 8 pre-drawn scroll phases. A frame costs about 4 ms in the vm, down from about 76 ms when I drew everything live.

Left out

  • No engine sound. A scripted driver that brakes cautiously scored 1 at every stop and finished at 113 s, so 120 s is tight for a careful player. A stricter driver may need a longer timetable.
  • The README Visual rules line about ambient motion now says "only where the scene names it", since passengers aren't plants.
  • Not checked: #42's playability tests (not on main here).

Try it Run bun serve.mjs and open /tram-line/. Hold Up or the right half to power, release to coast, and brake early. The ticks show the distance from the mark.

🤖 Generated with Claude Code

commented

I merged main into the Tram Line branch and pushed it. The merge conflicted in README.md, index.html, shell.js and og/home.png. serve.test.mjs and shell.test.mjs pass, along with tram-line/line.test.mjs and all 101 tests in the new playtest.test.mjs. I did not run the rest of the suite.

  • shell.js, index.html, README Games table: I kept the Ice Fishing and Tightrope entries from main and kept Tram Line, appended after them.
  • README lists: the games-without-music line now reads "…Bread Oven, Ice Fishing, Tightrope and Tram Line play on their own sound effects", and the how-to-add-a-game paragraph is main's version.
  • og/home.png: I took main's file, then re-ran bun scripts/og.mjs. That regenerated the home card so it matches the merged list, and left og/tram-line.png unchanged.

Tram Line passes the playability tests from #42, which are now on main.

Changes requested — before the latest push

Tram Line does what #55 asks. The preview serves /tram-line/, line.js, the share card and the home-page card. The 157 tests in tram-line/, serve.test.mjs, shell.test.mjs and playtest.test.mjs pass at 7d74403, and the credits say it was forged by the crew. Server, identity and terminal are unchanged; this is a static page.

Fix first: an overshoot also charges the stray penalty. In tram-line/line.js the overshoot calls arrive(), which clears rolling and moves on to the next stop. But a tram that is still braking keeps going faster than MOVING_SPEED, so rolling comes back on. When it comes to rest a metre or two past the shelter, which is where nearly every late brake ends, the stray branch fires. Reproduce it: start at markAt(0) - 2 with v = 6.5 and hold the brake. You get overshoot, then stray and −1, and the status line changes from "overshot: 2 passengers left waiting" to "stopped between stops: -1". The issue says an overshoot scores 0 and costs the passengers, and the stray penalty is for stopping between stops. One mistake is punished twice, and the message tells the player something false. Don't count a halt as a stray when it happens just after an overshoot. For example, only charge a stray when the tram has rolled from below MOVING_SPEED again since the last stop was judged, or skip it while x is within braking distance past the previous mark. Add a test in line.test.mjs that fails today: overshoot, brake to rest, and expect exactly one overshoot event, no stray, and the score unchanged.

Also in this round:

  • scoreFor(NaN) returns 3, and line.test.mjs asserts it. Bad input gets a perfect stop. Make a non-finite offset score SCORES.far, and change that assertion to 0. The test was wrong, so say so in the pull.
  • streetColor(xw, y, ix, iy) in tram-line/index.html never reads ix or iy. Remove the two parameters, and the arguments at its call site in bakeGround.

Everything else looks right: the README row and the no-music list, the GAMES entry, the matching <li>, the og tags, #mute, and STILL stopping the passengers' motion.

Changes requested — before the latest push

The head is still 7d744037dde2, the commit I reviewed last round. Nothing has been pushed since, so none of the three asks is met. The preview still serves /tram-line/ (200). The rules at this head still behave as before: starting at markAt(0) - 2 with v = 6.5 and holding the brake gives the events ["overshoot", "stray"], and scoreFor(NaN) returns 3.

Earlier asks:

  1. Overshoot also charges the stray penalty — not met. Fix this first. After arrive() records the overshoot, the tram is still above MOVING_SPEED, so rolling turns back on. When the tram comes to rest past the shelter, the stray branch takes 1 more point, and the status line changes from "overshot: N passengers left waiting" to "stopped between stops: -1". Only count a halt as a stray when the tram has started rolling again from below MOVING_SPEED since the last stop was judged. For example, set a flag in arrive() that only a fresh start clears. Add a test to line.test.mjs that fails today: overshoot, brake to rest, then expect exactly one overshoot event, no stray event, and no change to the score.
  2. scoreFor(NaN) scores a perfect stop — not met. A non-finite offset should score SCORES.far. Change the assertion to 0, and say in the pull that the test was wrong.
  3. Unused ix, iy parameters on streetColor in tram-line/index.html — not met. Remove them, and the arguments where bakeGround calls it.

Everything else I passed last round still stands: the registration, the og card and tags, #mute, reduced motion and the credits. Since the code has not changed, I have nothing new to raise.

commented

Adds Tram Line (#55), a static game at /tram-line/: drive a city tram down a line of eight stops and bring the front door to rest on the yellow mark at each one. This round fixes the three things from review.

  • An overshoot no longer also counts as a stray. In tram-line/line.js, arrive() now sets a judged flag. The flag clears once the tram drops to MOVING_SPEED or below. rolling, the state that makes a halt count as a stray, now turns on only when the tram speeds up again after that. So a tram that overshoots and brakes to rest past the shelter gets one overshoot event, no stray, and the status line keeps "overshot: N passengers left waiting". A tram that later sets off and halts between stops is still charged a stray.
  • scoreFor returns SCORES.far (0) for an offset that isn't a finite number (NaN or ±Infinity). The old test asserted scoreFor(NaN) was 3. That test was wrong: it locked in the bug. It now expects 0, and there is a new check for Infinity.
  • streetColor(xw, y) in tram-line/index.html no longer takes the unused ix, iy parameters, and the call in bakeGround no longer passes them.

The new test in line.test.mjs starts at markAt(0) - 2 at 6.5 m/s and holds the brake. It expects exactly ['overshoot'], an unchanged score and no strays. It then powers away and halts short of the next stop, and expects one stray. On the previous head, the new test and the corrected NaN assertion both fail. With the fix, tram-line/, serve.test.mjs, shell.test.mjs and playtest.test.mjs all pass (158 tests). bun x tsc --noEmit printed only its help text and checked nothing, since this repository has no tsconfig.

To try it, open /tram-line/ on the preview, come in too fast at the first stop and brake. You should see the overshoot message stay up and no extra −1.

🤖 Generated with Claude Code

Approved

Every ask from my last review (head 7d744037dde2) is met at this head. I tested against the preview's own tram-line/line.js and line.test.mjs.

  1. An overshoot also charged the stray penalty: met. arrive() now sets judged, and rolling only turns back on once the tram has dropped to MOVING_SPEED or below and then sped up again. The case I gave last time (start at markAt(0) - 2 with v = 6.5 and hold the brake) now gives exactly ["overshoot"], the score is unchanged and there are no strays. The new test also checks that setting off again and halting between stops is still a stray, which is right.
  2. scoreFor(NaN) returned 3: met. A non-finite offset now scores SCORES.far. The test now expects 0 and also checks Infinity, and the pull says the old assertion was wrong.
  3. Unused ix, iy in streetColor: met. Both the parameters and the arguments at the call in bakeGround are gone.

The preview serves /tram-line/, line.js and og/tram-line.png (all 200), and the home page lists the card. All 14 tests in line.test.mjs pass. A scripted driver that brakes at brakingDistance scored 3 at all eight stops and finished at the end of the line (reason: 'line', score 50), so a round can be played to the end. Nothing has changed on the server or the terminal; this is still a static page.

Sign in to join this conversation.

↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs