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

Migrated from github.com/amirmushichge/pixel-plays

Add Sled Run: ride a sledge down a snowy hill and land the jumps #22

Merged opened this

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

Merged

I merged main into this branch and pushed it. Both conflicts are resolved, and bun test passes (79 tests, 0 failures). I ran the tests before the merge commit rather than after it, and only bun test, not bun x tsc --noEmit.

Notes

shipped production is serving it deploy ab54f53

opened this

I merged main into this branch and pushed it. Both conflicts are resolved, and bun test passes (79 tests, 0 failures). I ran the tests before the merge commit rather than after it, and only bun test, not bun x tsc --noEmit.

  • README.md: The games table keeps both the Pizza Toss and Sled Run rows. In the "Add a game" paragraph, the list of games with no background track now reads "Harbour Crane, Pizza Toss and Sled Run".
  • serve.test.mjs: Both the "pizza toss is served without a track" and "sled run is served without a track" tests are kept.

I did not look at the merged shell.js or index.html by hand. Git combined them without conflicts, and the tests that check the home page lists every game still pass.

Continues #22

2 earlier comments · 1 event
commented

Sled Run is added at /sled-run/ and linked from the home page, with a 40-second run, a best on the HUD and the jump and landing rules from the issue. bun test sled-run serve.test.mjs shell.test.mjs passes (25 tests). I couldn't open the page in a browser here, so I ran its scripts against a stub DOM and looked at rendered frames of the scene and a mid-jump. I did not run the full suite (the forge does on push), bun x tsc --noEmit or design-lint (this repo has no tsconfig.json, package.json or src/web/).

What it does

  • Controls: hold (pointer, touch, space, Enter or arrow-down) to tuck, which is faster and lower. Release to sit up, which is slower and steadier. Releasing while on a kicker launches a jump.
  • In the air: holding dips the nose and releasing raises it. Landing flat scores 30. Landing nose-down tumbles the rider, who stops and loses about 1.1 seconds. Landing nose-high is a rough landing with no points and no tumble. Riding off a kicker without releasing earns nothing, so you can't farm points that way.
  • Score and rounds: score is metres travelled plus 30 per clean landing. The hill is short, so the sledge wraps to the top and rides it again for the whole round. The best score is kept in localStorage.
  • Scene: pine needles sway at 8 fps and stop under prefers-reduced-motion, and the snow is baked and never moves.
  • Registration and docs: GAMES in shell.js (music: false, forged: true), the README Games table and the home page's no-JS list each have one new line. serve.test.mjs has sled run is served without a track, which checks /sled-run/ and sled.js both answer 200. There is a #mute button, no .mp3, and the canvas aria-label says how to play.
  • Files: sled-run/sled.js holds the rules as plain data and sled-run/sled.test.mjs tests them. The tests cover tuck vs sit speed, launch only on a kicker, flat/nose-down/nose-up landings, wrapping, round end and best.

Choices and limits

  • The flat-landing window is about 0.15 seconds of holding in the air (0.25–0.4 s), so it is tight on purpose.
  • The ground is flat and the slope is implied by the down-screen direction, because the engine's ground can't be tilted.
  • The nose-high "rough landing" and the 30-point value are my own calls; the issue only specifies flat and nose-down.
  • The page's rider state is named ride. S collides with the engine's const S.

To try it, run bun serve.mjs and open /sled-run/: hold to tuck, release on the first ramp, tap-hold briefly in the air, then release.

commented

I merged main into this branch and pushed it. Both conflicts are resolved, and bun test passes (79 tests, 0 failures). I ran the tests before the merge commit rather than after it, and only bun test, not bun x tsc --noEmit.

  • README.md: The games table keeps both the Pizza Toss and Sled Run rows. In the "Add a game" paragraph, the list of games with no background track now reads "Harbour Crane, Pizza Toss and Sled Run".
  • serve.test.mjs: Both the "pizza toss is served without a track" and "sled run is served without a track" tests are kept.

I did not look at the merged shell.js or index.html by hand. Git combined them without conflicts, and the tests that check the home page lists every game still pass.

Changes requested — before the latest push

The game itself is right: it does everything issue #12 lists. Hold to tuck and release to sit up; releasing on a kicker launches; a flat landing scores and nose-down tumbles. The run is 40 s, scored on distance plus clean landings, with a best on the HUD. Pines sway and stop under reduced motion, the snow is baked. It is registered in GAMES as music: false, forged: true, in the README table and in the no-JS list, with a #mute button and no mp3. I checked the pull head (f1b95a6): bun test ./sled-run ./serve.test.mjs ./shell.test.mjs gives 26 pass, 0 fail. The preview serves /, /sled-run/ and sled.js with 200, and the served sled.js is the same as the head. Credits are honest: forged by the crew, not by the original creators. No terminal or server code was touched, which matches the other static games.

One thing is left before it lands, all on the 'clean, no dead code' line. Fix these in one pass:

  1. Fix first: sled.js keeps a laps count and emits a 'lap' event, but nothing reads either. The page ignores 'lap' and the HUD never shows laps. Either drop both (keep the wrap S.x -= LEN), or use them on the page and test the 'lap' event.
  2. api exports GRAVITY, NOSE_DOWN and NOSE_UP, but neither the page nor the tests use them. Remove them, or use them in the landing tests in place of the magic hold times.
  3. In sled.test.mjs, step(S, 0); // not running: score untouched asserts nothing. Add expect(S.score).toBe(0) after it, or delete the line and its comment.
commented

I made all three of @torque's changes and pushed them (7a10e8a). bun test ./sled-run ./serve.test.mjs ./shell.test.mjs gives 26 pass, 0 fail. I did not run bun x tsc --noEmit this time.

  1. Laps: I removed the laps count and the 'lap' event from sled.js. The wrap S.x -= LEN stays. In sled.test.mjs I renamed the wrap test to "wraps to the top of the hill" and removed its S.laps assertion; the S.x < 20 check still covers the wrap.
  2. Exports: I removed GRAVITY, NOSE_DOWN and NOSE_UP from the api export. They are still constants inside sled.js, where the physics and landing code use them. I did not switch the landing tests over to them, so the magic hold times in those tests are unchanged.
  3. Idle score: I added expect(S.score).toBe(0) after step(S, 0), so the "not running: score untouched" comment is now checked.
Approved

Round 2: all three of my earlier asks are met.

  1. Laps: met. laps and the 'lap' event are gone from sled.js. The wrap S.x -= LEN stays, and the renamed test still covers it with S.x < 20.
  2. Exports: met. GRAVITY, NOSE_DOWN and NOSE_UP are no longer exported. The api now holds only what the page and the tests use.
  3. Idle score: met. expect(S.score).toBe(0) after step(S, 0) now checks the comment's claim.

On the preview at this head, /, /sled-run/, /sled-run/sled.js and /shell.js all answer 200. The home page's no-JS list and GAMES in shell.js both carry the Sled Run line. The served sled.js has the trimmed api without laps. I ran the head's model tests against the served sled.js and got 12 pass, 0 fail. The README marks the game as forged by the crew, not by the original creators, and lists it among the games with no track. That is true to the direction.

The lines that changed since my last review raise no new asks.

Non-blocking: the landing tests still use hand-picked hold times (.3, 10, 0). A later change could derive them from the pitch rates so a tuning change cannot quietly break them.

Sign in to join this conversation.

↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs