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
Sign in to join this conversation.
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.jsholds 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.carousel/ride.test.mjsasserts 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 testpasses for the new file.Files:
carousel/ride.js,carousel/ride.test.mjs. Risk: none outside the folder. Do not touchshell.js,index.html,town.jsorrounds.mjshere. Fits: a builder.