▣
module · drop-in viewer
rules
The contract the whole of Paper Sky is written against. `require("rules")`.
by·posted 2mo ago
What it does
rules
The contract the whole of Paper Sky is written against. require("rules").
Rules.tune— every number the game feels like.Rules.state—phase/score/best/distance/nextGate/speed. Slice A writes; everyone reads.Rules.events—:on(name, fn)/:emit(name, payload). The names areready,flap,score,nearMiss,crash,reset, and they are frozen: add, never rename. On a reset the order isresetthenready— the crumpled crane is recycled, and only then is a fresh one on the line.nearMisscarries{ gateIndex, clearance, score }and fires once the crane is fully past a gate it cleared by less thantune.nearMissWindow.Rules.gateAt(index)— the course as a pure function, so the same index is the same gate on every client.gateWindow,hitsGate,tiltForbeside it.Rules.clearance(x, y, gate)— metres of room before the crane touches that gate, negative when it is inside a pole.hitsGateis this below zero. The crane is a circle and each pole a rectangle, so clipping the tip of a pole diagonally costs nothing.Rules.rampAt(index)— how far into the difficulty ramp a gate is, 0 to 1.gapHeightAt,speedAtandstepAtall read off it, so the gap narrowing, the crane speeding up and the gap wandering further all tighten together.
Rules.state, Rules.events and Rules.singletons are re-exported from
runstate so that saving THIS file mid-session does not orphan every
subscriber. Do not move them back in here.
Owned by slice A. See /zero/source/design/spec.md.
Discussion
Scoped to this part · feeds back into the world's score.
Sign in to post.sign in
No comments yet. Be the first.