What it does
A course is built from a road-data road file. It can be stages one after another, where the road widens into two,
the side the car is on picks the route and the chosen road curves away, ending at one of several goals; or a single
closed circuit raced in laps. The clock starts from a table, checkpoints and laps extend it by difficulty up to a cap,
and a score threshold can add bonus time. A qualifying lap can set the grid from lap-time thresholds, with a bonus for
the better places.
Traffic spawns on the horizon up to a cap per stage, cruises in its lanes, moves out of the player's lane, slows when
hemmed in and scores when you overtake it. Rival race cars brake for the bend ahead and take an inside line. Contacts
are swept in a scaled-depth field: running into the back of traffic can be a rebound that costs speed, while
crashes are chosen by impact speed, a bump, a spin, a flip with the occupants thrown out, an explosion, a rider thrown
off or a dead stop, with the clock running on before a restart on the road.
The vehicle is a vehicle-handling car or bike, with a two or four-speed shifter, lean and a turbo, and the race
passes it the road's surfaces and bounds. Scoring pays by a speed table, distance, overtakes, passes, the grid bonus
and the time left at the end, and scores can roll over. Everything is deterministic in whole 1/60 second steps, and
scene() hands the road, the split strips and every field object to a presenter.
Features
- Branching routes — road splits decided by the car's side, a world map of stages and several endings.
- Circuits and qualifying — laps, a qualifying lap with grid thresholds and bonuses, and rival cars.
- The clock — start times by difficulty, checkpoint and lap extensions, a cap, score bonuses, and a choice to stop or coast when time is up.
- Traffic — horizon spawning with caps per stage, lane keeping, moving aside, slowing when hemmed in, random lane changes and overtake points.
- Rivals — grid cars that brake for bends, take the inside line and score when passed.
- Crashes by speed — bump, spin, flip, explosion, rider thrown off or stop, per kind of thing hit, with restart rules.
- Scoring — a speed table, distance, overtakes, passes, grid bonus, time bonus and rollover.
- Cars and bikes — any vehicle-handling car or bike, with assist by difficulty and surfaces such as puddles.
- Tunnels — walls that narrow the road's bounds and solid faces at each mouth.
- Five presets —
outRunPreset,polePositionPreset,hangOnPreset,superHangOnPresetandnightDriverPreset, each at Easy, Normal or Arcade. - Hooks for rules on top —
addScore,crashIntoandresumelet other packs add their own scoring, crashes and continues.
Good for
- Branching road trips in the style of the 1986 arcade Out Run, with fifteen stages, traffic and five endings.
- Circuit racers with qualifying in the style of the 1982 arcade Pole Position.
- Motorbike racers in the style of Hang-On and Super Hang-On, with riders thrown on a crash and four continents.
- Night drives in the style of the 1976 Night Driver, where only the roadside posts are drawn.
- Mixes of your own, a bike on a road-trip map, traffic on a circuit, a rally stage with gravel and no traffic.
- Racing rules under other games, such as police pursuits and combat rallies built on top of it.
Make it yours
The config is plain data and every preset is a starting point. You choose the road file and entry, how far ahead the road reaches, the vehicle and its assist, surfaces and bounds, the player's sprite and hit box, the clock, traffic kinds, speeds, caps and behaviour, rivals, qualifying and laps, crash classes per kind of contact, scoring, endings, stage banners and steering. The presets take a difficulty and an optional road file, plus their own options: laps, rivals and skipping qualifying for the circuit, a continent for the bike racer, a track, a reverse set and a time for the night drive.
Two very different races from the same rules: a road trip of stages with splits, a checkpoint clock, traffic that rebounds you and five goals; or a four-lap circuit with a qualifying lap, a grid of rivals that brake for the bends, and a car that explodes and reappears when it hits a sign. Swapping the vehicle and player sprite puts a motorbike on the road-trip map.
A quick look
A race from the preset, stepped with input and drawn with the pseudo-3D view:
const RR = game.roadRacer;
const race = RR.createRoadRace(RR.outRunPreset({ difficulty: "normal" }));
race.start();
race.tick(dt, { throttle, brake, steer, gear: lever /* 0 LOW, 1 HIGH */, boost });
for (const e of race.drain()) present(e); // signal, go, stage, checkpoint, extend, fork, overtake, rebound, crash, lap, qualified, goal, bonus ...
view.draw(race.scene()); // road-view-pseudo3d draws the road leg, the split strips and every field object
Works with
road-data— required: the road file, its forks, markers, scenery and tunnels.pseudo-road— required: the projected road built from each leg.scaled-depth— required: the field of traffic, rivals, scenery and debris, and swept contacts.vehicle-handling— required: the player's car or bike.road-view-pseudo3d— draws the race's scene.road-pursuitandroad-assault— police chases and combat rallies built on this race.track-racer— for top-down circuits, androad-combatfor a vertical road shooter.
Good to know
- Road shapes come from the road file and are authored to each stage's character, not taken from the original games' data.
- Traffic is rules-driven sprites on lanes, and rivals use a corner-speed rule rather than full handling.
- Some preset values, such as lap times, bike clocks and score rates, are estimates where no source gives them.
- One player and no sound, though the events are there for it.






