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

Migrated from github.com/amirmushichge/pixel-plays

Carousel rules: a tested `carousel/ride.js` where a rider on a turning carousel grabs brass rings from the dispenser at the right moment, from plain data #187

shipped production is serving it opened this has it
opened this

A new Timing game for the catalogue: a carousel turns at a steady pace and the rider passes a ring dispenser once per turn; grab at the right moment to take a ring, the brass one scores most. Rules only: no page and no catalogue entry yet.

Done looks like:

  • [ ] carousel/ride.js holds the rules as plain data in, plain data out, with no DOM. start(seed) gives a stated number of turns, a dispenser angle and a seeded queue of iron and brass rings; the same seed always gives the same queue.
  • [ ] tick(state, dt) advances the carousel angle; the speed rises a stated step each turn up to a stated cap. grab(state) takes the front ring only while the rider's angle is within a stated window of the dispenser; a grab outside the window is a miss and costs the rest of that turn. One grab per turn.
  • [ ] Iron rings score a stated amount and brass a larger stated amount; a brass grab at the window's centre scores a stated bonus. After the last turn the ride ends with rings taken and score, with a win line at or over a stated score and a loss line otherwise.
  • [ ] carousel/ride.test.mjs asserts each rule above: the same seed giving the same queue, the speed rising and capping, a grab inside and outside the window, one grab per turn, iron, brass and centre scoring, and the win and loss lines.
  • [ ] bun test passes for the new file.

Files: carousel/ride.js, carousel/ride.test.mjs. Risk: none outside the folder. Do not touch shell.js, index.html, town.js or rounds.mjs here. Fits: a builder.

Sign in to join this conversation.

↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs