What it does
A round session builds each stage from its definition: the level from platform-map, lifts and belts from
platform-movers, the enemies, emitters and pipes from platform-enemies, all moved by platform-walker. It then
applies the rules those packs deliberately leave out. Each step it sets the player's intent from your input, reads the
walker's landings, bumps, hazards and crushes, and decides deaths, scores, bumps and the end of the stage.
Objectives are data: reach a zone, take every item, clear a roster of enemies, remove tagged cells such as rivets by crossing them, or collect a count of coins with a bonus for a perfect run. A stage can need several at once. A bonus timer counts down, can kill, end the stage or do nothing at zero, and pays its remainder on a clear. Stages run in sequences per level, with a loop point, interludes before and after, and a stage builder that can change a stage by level, loop, attempt or difficulty.
Rules you need beyond the built-in ones come as modules: small objects with hooks at fixed points of each step, each
with its own state that snapshots carry. The floor-bump family, bumps from below, kicks and their chain, the POW block,
freezing floors, icicles and fireballs, is one such module, bumpModule(), on by default. Two complete arcade presets,
girder-climb and floor-bump, are built only from this public API.
Features
- Objectives — reach a zone, take every pickup, clear enemies of chosen kinds, remove tagged cells, or collect items with a perfect bonus, alone or together.
- Bonus timers — a start value, a step every so many seconds or per spawn, a choice of what happens at zero, a warning, and a payout on a clear.
- Pickups — hammers with a duration, reach and a profile patch that stops jumping and climbing, and scoring items.
- Kind rules — per enemy kind, whether contact kills, is harmless or collects, whether it can be smashed, jumped, bumped, kicked or POWed, and for how many points.
- Bumps, kicks and POW — floors bumped from below flip what stands on them, kicks chain for rising scores, and a POW block with limited uses carries between stages.
- Stage mechanics — sinks that turn one kind into another, retracting-ladder cell toggles, hazard zones, freezing floors, icicles, fireballs and scheduled spawns placed by cycle, at random, opposite the player or at the far edge.
- Deaths and lives — falls, hazards, leaving the screen and crushes by moving surfaces, restart or respawn, extra lives at thresholds and every so many points, and a high score.
- Sequences and interludes — stages per level with a loop point and a level cap, and timed before and after phases for your cut-scenes.
- Difficulty —
difficultyPresetfor Easy, Normal and Arcade, scaling speed, spawn intervals, timers, aggression, population and grace. - Rules modules — hooks for builds, bumps, contacts, enemy events and removals, with their own snapshot state.
- Deterministic — the same seed and input give the same game, with snapshot and restore and an attract mode that runs a stage without a player.
Good for
- Ladder-and-girder games in the style of Donkey Kong, with rivets, hammers, jump-over scoring and stage loops.
- Single-screen pipe-and-bump games in the style of Mario Bros, with flips, kicks, POW blocks and coins.
- Collect-then-exit platform levels, gather every gem and then reach the door, with lives and a level bonus.
- Timed platform challenges, where the bonus timer is both the threat and the score.
- Remixes of classic layouts, girder levels with bumpable enemies, or a collect-all brick level with a hammer.
- Arcade campaigns that loop with rising difficulty, extra lives and a high score.
Make it yours
Everything is the definition passed to createRounds: the stages and their sequence, the player's profile, lives,
extra lives, timings for each phase, the difficulty, the seed, the high score and the rules modules. Each stage sets
its map, movers, enemy kinds, emitters, spawns, objectives, timer, kind rules, pickups, bump, POW, sinks, toggles,
hazards, deaths, what a death does, and a policy hook for anything else. Map markers place gems, doors and spawns
from the level rows.
The same session runs very different games. A girder campaign with rivet objectives, hammers and a bonus timer that kills at zero is one. A wrapping single-screen arena with pipes, bumpable enemies, kicks, a POW block, coins and respawns is another. A custom level where you collect every gem and then reach the door, with barrels burning out and gems kept across deaths, is a third. A game with none of the floor-bump rules simply passes no modules.
A quick look
A one-stage game, reach the door before the timer runs out, and the frame loop:
const PR = game.platformRounds;
const rounds = PR.createRounds({
stages: { a: { map: { rows: level, legend: game.platformMap.defaultLegend() },
objective: { type: "reach", zone: { marker: "exit", w: 16, h: 16 } },
timer: { start: 1000, step: 100, every: 1 } } }, // pays the remainder on a clear
sequence: { levels: [["a"]] },
player: { profile: game.platformWalker.labPlayerProfile() },
lives: 3,
});
rounds.start();
rounds.tick(dt, { x: -1 | 0 | 1, y: -1 | 0 | 1, jump });
for (const e of rounds.drain()) { /* score, death, jump-over, smash, bump, kick, pow, stage-clear ... */ }
Works with
platform-map,platform-walker,platform-movers,platform-enemies— required: the level, the bodies, the moving surfaces and the enemies of every stage.girder-climbandfloor-bump— complete arcade presets built on it.enemy-capture— for bubble and snowball captures, instead of or as well as rounds.dig-trap— for dug holes that trap guards.render-auto,world-screenandtypography— to draw a session.platformer-2d— for physics traversal courses rather than arcade rounds.
Good to know
- Rules only: the session never draws, and cut-scenes are timed phases your presenter animates.
- One player; two-player alternation, attract-mode demo play and sound are not modelled.
- Snapshots hold the session but not its definition, so restore into a session built from the same definition.
- Hazard zones are static rectangles; a moving hazard is expressed as an enemy kind.






