What it does
The runner follows a path of straight stretches. Each stretch can end in a corner, left, right or a T-junction where either way goes on. A swipe inside the corner's turn window takes it; a runner that misses one runs off the edge. Tilting moves the runner across the path at a steady speed, so it can gather a line of weaving coins or steer past a broken edge, and it jumps over roots, fire and gaps and slides under arches. A barrier that does not span the path can be steered round, and from the side it is a wall that trips the runner once.
Tripping is a stumble that brings the chasers to the runner's heels; trip again before they drop back and they catch
it. A head-on hit or a fall ends the run. The endless path is built from chunks on runner-core, one straight stretch
each, with their obstacles, gaps, coins and pickups placed along and across them. Past a fork the player has not yet
chosen, both branches are shown, and the path carries on whichever way the runner goes.
The pack draws nothing. view() gives every stretch with its heading, length, width and gaps, every barrier, coin and
pickup, the runner and the chasers, all as world positions with stable ids, so your game places meshes and nothing
else. The run steps at a fixed rate, and it can be saved, restored and cloned, which is how the autopilot looks ahead:
it tries steering left, centre or right, with a jump or a slide now, a moment later or not at all, on a copy of the
run, and keeps the plan that lasts longest without a trip.
Features
- Corners and forks — stretches that end in a left or right turn or a T-junction, taken by a swipe inside the
turn window, with
canTurn()for a swipe prompt. - Tilt to steer — the runner moves across the path in proportion to the tilt, for coins, broken edges and trees.
- Jumps and slides — over roots, fire and gaps and under arches, with a slide in the air driving the runner down.
- Stumbles and chasers — a trip brings the chasers, a second trip inside the window ends the run, and barriers can be set to trip rather than crash.
- A built-in path —
templeChunksgives a start, roots, arches, fire, gaps, broken edges, trees, weaving coins, a gauntlet, power-ups, and corners and forks, harder further along. - Your own path — chunks of
barrier,gap,coins,powerandturnitems, checked byvalidateTurnRunner, which lists every fault. - Power-ups as data — a magnet, invisibility, a boost that takes corners and crosses gaps by itself, and a shield, with runner-core's shield, invulnerability, multiplier and speed to build more.
- A view to draw — stretches, barriers, coins, pickups, the runner and the chasers as world positions and headings, with both branches of an unchosen fork.
- Autopilot —
createTurnAutopilotplays the run by looking ahead on a copy, for an attract mode or a test. - Snapshots —
snapshot,restoreandclonefor saves, replays and lookahead.
Good for
- Endless runners on a turning path, seen from behind, in the style of Temple Run.
- Jungle, canyon or ruin escapes with roots to jump, arches to slide under and a pursuer close behind.
- Cart or sled rides with forks, where the player picks a branch at every junction.
- Mobile games played with swipes and the device's tilt.
- Attract modes and automated tests, with the autopilot playing the same rules as the player.
Make it yours
createTurnRunner takes the path's width, the runner's body (height, slide height, size, jump height and time,
slide time, steering speed and how early a turn may be swiped), the chunks that make the path and the opening
ones, the powerUps, the coin radius, and runner-core's run options for the speed ramp, scoring and stumbles. The
built-in path takes a width of its own, so a wider or narrower path keeps its obstacles in proportion.
Two different runs from the same rules: the built-in temple path, 4.2 units wide, its speed rising from 11 to 24 at 0.08 a second, with corners, forks and fire; and a path of your own chunks, much wider, with a long jump and quick steering, where long lines of arched coins run between gaps and only the occasional corner breaks the straight. Swap in your own power-ups, such as a longer magnet or a boost with a different speed, by passing new data.
A quick look
A run stepped from the player's input and drawn from its view:
const run = game.turnRunner.create({ run: { seed: 3 } });
if (game.input.keyPressed('ArrowLeft')) run.input('left');
run.steer(tilt);
run.step(dt);
const v = run.view();
for (const s of v.stretches) placeFloor(s.id, s.from, s.heading, s.length, s.width, s.gaps);
hero.x = v.runner.x; hero.z = v.runner.z; hero.yaw = v.runner.heading * Math.PI / 2;
Works with
runner-core— the endless run underneath: score, coins, speed, power-ups and stumbles.render-3d— meshes for the stretches, obstacles, coins and the runner.lane-runner-3d— for parallel lanes and swipes between them, rather than a path that turns.jetpack-runner-2d— for a side-on jetpack corridor.
Good to know
- Corners are square quarter turns, and stretches are straight: no slopes, curves or bridges over chasms.
- Past an unchosen fork only the next stretch is known, so the chunks after it are the same whichever way the runner goes.
- A path of very short stretches that keeps turning one way can cross itself in view.
- The built-in chunks are proved passable by the autopilot at top speed; chunks you author are yours to check, and the autopilot can help.






