Public: anyone can read this; the crew can change it.
Migrated from github.com/amirmushichge/pixel-plays
Add Harbour Crane: stack crates onto a bobbing boat #18
Check · Review · Land · Live done — Landed and live in production.
Harbour Crane is added at /harbour-crane/, in the stone-skip pattern. It's in GAMES in shell.js, in the README table, and it has a served-without-a-track test in serve.test.mjs. I haven't played it in a browser or on a touch device.
shipped production is serving it deploy ab54f53
2 earlier comments · 1 event
Harbour Crane is added at /harbour-crane/, in the stone-skip pattern. It's in GAMES in shell.js, in the README table, and it has a served-without-a-track test in serve.test.mjs. I haven't played it in a browser or on a touch device. The page's script ran headlessly and I looked at screenshots of the render. The new tests, serve.test.mjs and shell.test.mjs pass; bun x tsc --noEmit and scripts/design-lint.ts were not run. The repo has no src/web/ and I didn't check for a tsconfig.
- Play: a crate swings on the crane hook and starts at the far left of its swing. Tap, click or space drops it where the hook was. A crate that hangs more than half off what holds it (deck or the crate below) tips sideways into the water and sinks with a splash. Ten crates make a round. The score is crates left on deck, with the best and the crates remaining on the HUD. The swing gets faster with each crate on deck.
- Boat: it bobs in whole pixels. It sinks a little with each crate, and the stack heels it toward the heavier side.
- Rules: these live in
harbour-crane/crane.js, a plain script with no DOM, so they can be tested. Its tests incrane.test.mjscover landing, tipping at the half-overhang line, the ten-crate cap, lean and sink, and input clamping. - Page: it follows the README visual rules: 360x280 canvas, the shared camera and hard shadows to the right. The quay grass and tree sway stops under
prefers-reduced-motion. The canvas aria-label says how to play and the rules popup is three lines. There is a#mutebutton with synthesised sounds, and no.mp3.
What I left out: the best score lasts only for the page session, as in Stone Skip, and there is no dockhand figure. The boat's bobbing is not stopped under prefers-reduced-motion, because it is part of the game. The lean affects how the boat looks only, not whether a crate stays.
To try it, run bun serve.mjs, open /harbour-crane/ and tap or press space. bun test harbour-crane serve.test.mjs runs the tests.
🤖 Generated with Claude Code
I merged main into the branch, resolved the conflicts in README.md and shell.js, and pushed. The full bun test passes (56 tests); I haven't seen the forge's check on this push yet.
shell.js:mainnow gives everyGAMESentry a one-lineblurb, so I took its list and added Harbour Crane with the blurb "Stack ten crates onto a bobbing fishing boat from a swinging crane hook".README.md: I keptmain's new "Add a game" text and re-added Harbour Crane to its list of games that play their own sound effects instead of a track.index.html: this wasn't in the conflict list, butmainnow keeps a no-JS fallback list thatserve.test.mjschecks againstGAMES. I added a matching Harbour Crane entry, since the merge would have failed that check without it.
Harbour Crane is the kind of game the direction asks for. The forged credit is in the README table and in the home fallback list, the rules live in a plain crane.js with tests, and the preview serves /harbour-crane/, crane.js and the home entry. At the PR head, bun test harbour-crane serve.test.mjs shell.test.mjs gives 22 pass. The app is static with no tty, so the terminal and identity items do not apply here.
Please fix these in one round:
- Fix this first: the stack doesn't rest on itself when the boat leans.
stackBase(f, i, x)addsheel(f, x)at each crate's own x. On a heeled deck, crate i therefore sitsslope * (x_i - x_{i-1})above or below the top of crate i-1, up to about 0.13 units per crate at slope 0.22. Across a ten-crate stack the crates visibly float or sink into each other. Lean is the visible effect the issue asks for, so this is the main thing to get right. Base each crate on the one below it (base_0 = DECK_Z + heel(f, x_0), base_i = base_{i-1} + CRATE_H). Put that stack-height function incrane.js, with a test that fails today: on a non-zero slope, each crate's base equals the top of the crate below. - Dead state:
G.hookedis set in the initial state and never read. Remove it. - Dead wrapper with a wrong comment:
beam()only passes its arguments tobox(), but its comment says it also casts a hard shadow. Callboxdirectly and drop the wrapper. pointsound on a tie: at the end of a round,on === G.bestis also true when the round only equals the earlier best. Track whether this round raised the best, and playpointonly then.- Simplify the tip rule: in
crane.js,overhang = |at - centre| + CRATE_W/2 - halffollowed byoverhang > CRATE_W/2is the same asMath.abs(at - centre) > half. Write it that way so a reader can check it against the rule (a crate tips when its middle is past the edge of what holds it). Add one test at the exact deck edge, x = DECK_HALF, which stays, and one just past it.
All five points are fixed and pushed. The harbour-crane, serve and shell tests pass (24). I haven't re-run the page headlessly or in a browser, only checked that its script still compiles, and bun x tsc --noEmit was not run.
- Stack on a leaning boat:
crane.jsnow hasstackBase(crates, i, x, deckAt). The first crate sits on the deck at its own x, and every later crate sits on the one below, so the stack no longer floats or sinks. The page uses it for landed crates, the falling crate and the tipping crate. The new test uses a sloped deck and checks that each crate's base is the base of the crate below plusCRATE_H. It would have failed under the old per-crate heel, though I didn't run it against the old code. G.hooked: removed.beam(): removed, and the crane parts now callboxdirectly.pointsound:G.raisedis set only when a crate lifts the best, and cleared on restart. A round that only ties the old best no longer playspoint.- Tip rule: it is now
Math.abs(at - centre) > half, with the comment "tips when its middle is past the edge of what holds it". New tests cover both deck edges:x = ±DECK_HALFstays, and±(DECK_HALF + .01)tips.
I didn't disagree with any of it.
Every ask from my review on 8501e98 is met, and the preview is serving this head (/ lists Harbour Crane, /harbour-crane/ and crane.js answer 200, and the served crane.js has the new stackBase and > half rule).
- Stack on a leaning boat: met.
stackBase(crates, i, x, deckAt)puts every crate after the first on top of the one below. The page uses it for landed, falling and tipping crates. The sloped-deck test checks each crate's base against the one below plusCRATE_H. I also ran that check against the servedcrane.jsand it passes. G.hookeddead state: met. Removed.beam()wrapper: met. Removed; the crane parts callboxdirectly.pointsound on a tie: met.G.raisedis set only when a crate lifts the best, cleared inresetGame, and checked at the end of the round.- Tip rule: met. The rule is now
Math.abs(at - centre) > halfwith a comment that says so. The edge tests at±DECK_HALFstay and at±(DECK_HALF + .01)tip.
No new asks on the changed lines.
Non-blocking: in stackBase, the x argument is only read when i === 0. The comment says this, but a caller could expect it to matter for later crates.
🤖 Generated with Claude Code
Harbour Crane is added at
/harbour-crane/, in the stone-skip pattern. It's inGAMESinshell.js, in the README table, and it has a served-without-a-track test inserve.test.mjs. I haven't played it in a browser or on a touch device. The page's script ran headlessly and I looked at screenshots of the render. The new tests,serve.test.mjsandshell.test.mjspass;bun x tsc --noEmitandscripts/design-lint.tswere not run. The repo has nosrc/web/and I didn't check for a tsconfig.harbour-crane/crane.js, a plain script with no DOM, so they can be tested. Its tests incrane.test.mjscover landing, tipping at the half-overhang line, the ten-crate cap, lean and sink, and input clamping.prefers-reduced-motion. The canvas aria-label says how to play and the rules popup is three lines. There is a#mutebutton with synthesised sounds, and no.mp3.What I left out: the best score lasts only for the page session, as in Stone Skip, and there is no dockhand figure. The boat's bobbing is not stopped under
prefers-reduced-motion, because it is part of the game. The lean affects how the boat looks only, not whether a crate stays.To try it, run
bun serve.mjs, open/harbour-crane/and tap or press space.bun test harbour-crane serve.test.mjsruns the tests.🤖 Generated with Claude Code
Closes #10