What it does
createRooftop runs a course in fixed 1/60 second ticks with a single input, jump. Releasing the button while rising
shortens the jump, so a tap is a low hop and a hold is a long leap, and holding through a landing never jumps again by
itself. Roofs are buildings, girders or towers at different heights; building and tower sides are solid all the way
down, and girders have a shallow side. Obstacles are crates that slow you once, hazards and overhead beams that end
the run. Swept tests on the runner's body catch fast crossings, so nothing is skipped at high speed.
generateRooftop builds a course from a seed, a difficulty, a style and a roof count. A planner searches take-off
timing and jump length using the real speed, acceleration, gravity and collisions, and the course is accepted only
with a collision-free, crate-free winning sequence. That sequence comes back as a compressed recording you can replay,
so you can show a solution, test a course or build a ghost.
createRooftopStream turns the same rules into an endless run. Each time you land on the last roof of the stretch it
appends five more, certified from the position, speed and input you actually arrived with, so the course never asks
for a jump that cannot be made from where you are. Geometry behind the runner is discarded, and the input recording is
kept for exact rewind. If no continuation can be found, it reports the loss plainly so the player can rewind or
restart.
Features
- One-button jumps — tap for a hop, hold for a leap, with no accidental re-jump on landing.
- Rising speed — a starting speed that accelerates to a cap, cut by crates and resumed after.
- Varied rooftops — buildings, girders and towers at different heights, with solid faces and swept collision.
- Obstacles — crates that slow you, hazards and overhead beams that end the run.
- Seeded challenges — four difficulties, four styles (
skyline,girders,obstacles,mixed) and 3 to 30 roofs. - Certified courses — every generated course comes with a replayed winning input sequence and metrics.
- Endless streams — five roofs at a time, each stretch certified from your real arrival state.
- Rewind, replay and recording — exact rewind by replaying inputs, and recordings you can store and play back.
- Clear outcomes — state reports the distance, the obstacles hit, win or loss and the reason for it.
Good for
- One-button rooftop runners for mobile, where a tap and a hold are the whole control scheme.
- Daily challenge modes, a fixed seed and finish with a proof that it can be cleared.
- Endless runs that never generate an impossible gap.
- Ghosts and solution playback, from the certified recording.
- Tutorials and difficulty ladders, stepping from easy skylines to very-hard mixed courses.
Make it yours
Authored configs set the roofs and obstacles, the starting speed, maximum speed and acceleration, gravity, jump speed,
the death line, the start and the finish. The generator takes a seed, easy, medium, hard or very-hard, a style
and a roof count; difficulty raises the entry and capped speeds, the gaps and height changes and the default length,
while the seed changes roof widths and heights, gap order, building and girder layout and obstacle combinations.
Two different uses: a ten-roof girders challenge on easy with a fixed finish line and a replayable solution for a
daily puzzle; or a very-hard mixed endless stream that keeps extending from wherever the player lands, with rewind
when they fall.
A quick look
A seeded challenge, one tick of play, and an endless stream from the same seed:
import {generateRooftop, createRooftop, createRooftopStream} from '@phaser-ae/rooftop-runner-2d';
const level = generateRooftop({seed:29, difficulty:'hard', style:'mixed'});
const game = createRooftop(level.config);
game.tick({jump:true}); // one fixed 1/60-second tick
const endless = createRooftopStream({seed:29, difficulty:'hard'});
Works with
autorun-platformer-2d— for one-button courses with pause pads and wall reversals.platformer-2d— for manually controlled platforming where the player sets the pace.runner-core— for endless runners built from seeded chunks.
Good to know
- Generation and planning are bounded and can fail explicitly; a certificate proves a route exists, not that it is the best one or how hard it feels.
- Roofs and obstacles are axis-aligned boxes; there is no rotating terrain or general rigid-body contact.
- In a stream the geometry is bounded, but the input history grows with the length of the session.
- It draws nothing; your game renders the roofs, runner and obstacles from the state.






