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

Migrated from github.com/amirmushichge/pixel-plays

Rope Swing rules: a tested `rope-swing/river.js` where you let go of a seeded swinging rope at the right moment to land on the far bank across a widening river, in a two-file pull with a test file that runs in under a second #364

open not picked up yet opened this
opened this

A new Timing game for the catalogue. A rope hangs from an oak over the village river; it swings on a seeded rhythm and you let go so you land on the far bank, and each crossing the river is wider and the landing shorter. Rules only: no page and no catalogue entry yet.

Done looks like:

  • [ ] rope-swing/river.js holds the rules as plain data in, plain data out, with no DOM, in the same UMD shape as apple-bobbing/tub.js (exporting RopeSwing in the browser). start(seed) gives crossing one: the swing's period and phase, the river's width and the landing window, from the seed only, so the same seed gives the same crossings; no Math.random. A non-numeric seed falls back to 0.
  • [ ] step(state) advances the swing one tick; swing(state, tick) (exported) gives the rope's angle at a tick. release(state) lets go: the landing distance follows from the angle at that tick, and a landing inside the window scores more the nearer its centre. Each call refuses with a reason and returns the same state while you are in the air, or once the game is over.
  • [ ] A landing short of or past the bank is a splash and costs one of three lives; the crossing starts again. Each landing moves on to a wider river with a narrower window. The game ends with a line naming crossings made and score when lives run out, and is won with a win line after the sixth crossing. The state reports crossing, lives, score and the rope's angle for the HUD; no call mutates its input.
  • [ ] rope-swing/river.test.mjs asserts each rule above: same seed same crossings; a release at the best tick lands at the window's centre, one at the window's edge lands for the smaller score and one just outside splashes; a splash costs a life; each refusal with its reason; each crossing is wider and narrower; the loss line and the win line.
  • [ ] rope-swing/river.test.mjs loads no page and starts no renderer or server: it calls the rules module directly and runs in under one second on its own (bun test rope-swing/river.test.mjs). The pull states the measured time. bun test passes.

Files: rope-swing/river.js, rope-swing/river.test.mjs: a two-file pull. Risk: none outside the folder. Do not touch shell.js, index.html, town.js, rounds.mjs, forge.json, scripts/, playtest.test.mjs or serve.test.mjs here. Fits: a builder.

Sign in to join this conversation.

↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs