The pack
platformMovers
function platformMovers(): Pack<{ platformMovers: typeof api }>
Install the renderer-independent platform movers API.
Helpers
createMovers
function createMovers(o: MoversOptions): Movers
Create a set of moving surfaces.
Types
BeltMover
interface BeltMover extends MoverCommon
A conveyor belt that carries riders and may switch direction on a timetable (Donkey Kong 50 m).
type: "belt"— Belt.x: number— Centre x.y: number— Standing line.speed: number— Belt speed, units per second, positive to the right.switchEvery?: number | number[] | null— Seconds between direction switches: one number, a cycle of durations, or null never. Default null.
CrumbleMover
interface CrumbleMover extends MoverCommon
A platform that shakes once stood on, then falls or vanishes, optionally respawning.
type: "crumble"— Crumbling platform.x: number— Centre x.y: number— Standing line.delay?: number— Seconds of shaking after the first rider before it gives way. Default 0.5.fall?: "drop" | "vanish"— 'drop' falls away under gravity (drawn), 'vanish' disappears. Either way riders fall. Default 'drop'.gravity?: number— Gravity for 'drop', units/s². Default 500.respawn?: number | null— Seconds until it reappears, or null never. Default 3.
ElevatorMover
interface ElevatorMover extends MoverCommon
A column of platforms moving continuously up or down, each re-entering at the far end (Donkey Kong 75 m).
type: "elevator"— Elevator.x: number— Centre x of the column.top: number— Highest standing line.bottom: number— Lowest standing line.speed: number— Speed, units per second.count?: number— Platforms in the column. Default 3.direction?: "up" | "down"— 'up' or 'down'. Default 'up'.
MoverCommon
interface MoverCommon
Fields every mover shares. Positions are the surface's TOP-CENTRE: the middle of its standing line.
id: string— Unique id; surfaces areid(orid-0,id-1... for elevators).width: number— Surface width, world units.thickness?: number— Thickness below the standing line (drawn; blocks heads whensolid). Default 4.solid?: boolean— Also blocks rising heads (a bump) instead of being jump-through. Default false.traction?: number— Rider traction (1 normal, lower is slippery). Default 1.belt?: number— Conveyor speed carried by the surface itself (for belts use type 'belt'). Default 0.hazard?: boolean— Touching it is a hazard. Default false.bounce?: number— Launch speed for bodies that land on it (a spring pad). Default 0.active?: boolean— Starts active. Default true.kind?: string— Free classification for renderers ('lift', 'cart', 'girder'); defaults to the type.
MoverDef
type MoverDef = PathMover | ElevatorMover | BeltMover | SwingMover | CrumbleMover | TimedMover | StaticMover
Any mover definition.
MoverEvent
type MoverEvent = | { kind: "crumble-start"; id: string } | { kind: "crumble-fall"; id: string } | { kind: "respawn"; id: string } | { kind: "belt-reversed"; id: string; speed: number } | { kind: "elevator-wrap"; id: string; surface: string } | { kind: "arrived"; id: string; point: number } | { kind: "appear"; id: string } | { kind: "disappear"; id: string } | { kind: "triggered"; id: string }
Events from drain().
MoverPiece
interface MoverPiece
Render state of one surface.
id: string— Surface id.mover: string— Mover id.type: MoverDef["type"]— Mover type.kind: string— Classification.x: number— Top-centre x.y: number— Standing line y.width: number— Width.thickness: number— Thickness.visible: boolean— Visible (crumbles keep drawing while they fall).active: boolean— Standable this step.warn: number— 0..1 warning level (shaking crumbler, timed platform about to vanish).angle: number— Rope angle from vertical (swing), radians.pivot: MoverPoint | null— Pivot (swing) or null.beltOffset: number— Belt travel so far (for animating treads), units.belt: number— Current belt speed or 0.snapped: boolean— Moved discontinuously this step: renderers should snap.
MoverPoint
interface MoverPoint
A point in world units.
x: number— World x.y: number— World y.
Movers
interface Movers extends SurfaceProvider
A set of moving surfaces: a SurfaceProvider plus controls and render state.
step(dt: number, riders?: RiderMap): void— Advance one step with the riders from the walker world (world.riders()); a world calls it for you.surfaces(): readonly Surface[]— The current surfaces.pieces(): MoverPiece[]— Render state of every surface.ids(): string[]— Mover ids.reverse(id: string): void— Reverse a path, belt or elevator.setSpeed(id: string, speed: number): void— Set a path, belt or elevator speed (units per second; negative belt speed runs left).setActive(id: string, on: boolean): void— Enable or disable a mover's surfaces (disabled surfaces cannot be stood on).trigger(id: string): void— Start a rider-triggered path or a crumble now.reset(id: string): void— Put a mover back to its initial state.add(def: MoverDef): void— Add a mover at runtime.remove(id: string): void— Remove a mover.drain(): MoverEvent[]— Events since the last drain.snapshot(): MoversSnapshot— Serialisable state.restore(s: MoversSnapshot): void— Restore a snapshot of the same definitions.
MoversOptions
interface MoversOptions
Options for createMovers.
id?: string— Provider id. Default 'movers'.movers: MoverDef[]— Mover definitions.
MoversSnapshot
interface MoversSnapshot
Serialisable state.
movers: MoverState[]— Mover states, in definition order.surfaces: Surface[]— Surfaces as of the last step.events: MoverEvent[]— Undrained events.
PathMover
interface PathMover extends MoverCommon
Moves along authored points.
type: "path"— Path platform.points: MoverPoint[]— Waypoints for the top-centre, at least two.speed: number— Speed along the path, units per second.mode?: "ping-pong" | "loop" | "once"— 'ping-pong' back and forth, 'loop' round a closed path, 'once' to the end and stop. Default 'ping-pong'.dwell?: number— Seconds to wait at each waypoint. Default 0.trigger?: "always" | "rider"— 'always' moves from the start; 'rider' waits until something stands on it. Default 'always'.phase?: number— Start this far along the path, 0..1 of its length. Default 0.
StaticMover
interface StaticMover extends MoverCommon
A surface that does not move (bridges, ledges added at runtime).
type: "static"— Static surface.x: number— Centre x.y: number— Standing line.
SwingMover
interface SwingMover extends MoverCommon
A level platform on a pendulum.
type: "swing"— Swinging platform.pivot: MoverPoint— Pivot point.length: number— Rope length from pivot to standing line.amplitude: number— Peak angle from vertical, radians (positive swings right first).period: number— Seconds per full swing.phase?: number— Start this far through the swing, 0..1. Default 0.
TimedMover
interface TimedMover extends MoverCommon
A platform that appears and disappears on a timetable.
type: "timed"— Timed platform.x: number— Centre x.y: number— Standing line.on: number— Seconds present.off: number— Seconds absent.phase?: number— Seconds into the cycle at the start. Default 0.warn?: number— Seconds before vanishing during which renderers should warn (flash). Default 0.5.


