What it does
You build a game from a config, call tick with the player's input, and read events back. The input is a digital
stick, or an absolute target from an analog stick or the pointer that the runner moves towards. He moves freely on
his depth plane, or runs on the ground where bushes trip and stall him, and holding fire gives continuous rapid fire
with a cap on shots in flight. The camera follows him and the horizon follows his height, as set in the config.
A stage is data: a length and speeds by distance, a ground and an optional ceiling, scenery streamed from sections (lethal or tripping, destructible or not), waves of formations on camera-frame paths with mirrored variants, and bosses in order. Kinds fire on schedules with bursts, spreads and depth windows, and can be hurt only while a vulnerability window is open. Projectiles can home and then commit, so a late sidestep still dodges.
Bosses are built from parts. A serpent's body trails its head's track and deflects shots while only the head takes hits through colour stages; a core can hide behind an orbiting shield that must fall first, or that flies at you when the core dies; cores can launch waves or throw ground obstacles; squadrons leave when their timer runs out; and a stage with several bosses is a boss rush. Bonus stages put the hero on an invincible mount that smashes scenery for a tally. Around all this the pack keeps the score, a creeping distance score, extra lives, deaths and respawns, stage progression with an ending or a loop, and snapshot and restore.
Features
- Free flight or running — digital speeds or an analog target, a ground that trips a running hero, and a camera that follows him.
- Rapid fire — a held gun with a fire interval, a shot speed and range, and a cap on shots in flight.
- Scenery by distance — streamed trees, rocks, columns and the like, each lethal, tripping, destructible or indestructible.
- Formations — waves on authored depth paths with mirrored variants, offsets, counts and timers.
- Enemy fire — schedules per kind with bursts, spreads, depth windows and open-only fire, and homing projectiles that commit.
- Part-built bosses — serpents, shielded cores, squadrons, invulnerable carriers that launch waves, cores that throw obstacles, and boss rushes.
- Bonus rides — an invincible mount that smashes scenery, with a tally per object.
- Scoring and lives — points per kind, a creeping score, extra lives by threshold and interval, one-hit deaths or an energy bar.
- Three difficulties — Arcade, Normal and Easy, scaling fire, projectile speed, scroll speed, hit box, timers and lives.
- Two presets — every stage of the classic in its order, and a canyon game that changes the view, the rules and every stage.
Good for
- Third-person into-the-screen shooters over a checkerboard ground, in the style of Space Harrier.
- Dragon riders, by making every stage a bonus ride with lethal kinds as well as smash kinds.
- Canyon flights, with mirrored walls, flight only and an energy bar, as the second preset shows.
- Bullet-curtain variants, by giving formations dense bursts and spreads and turning running off.
- Boss-heavy arcade games, where serpents, shielded cores and rushes are configuration rather than code.
Make it yours
The config is plain data: a preset builds it and your game edits any field. The view sets the screen, focal length, horizon, how the horizon follows height and how far the camera follows the hero. The player sets his box, bounds, speeds, whether he runs, trip time, hits per life and invulnerability. The gun, the kinds (hit points, points, lethality, windows, fire), the projectiles, the paths, the stages, the bosses, scoring, timings, the ending or loop and the difficulty multipliers are all fields too.
spaceHarrierPreset takes difficulty, lives, the extra life, the start stage, the stages and a seed, and builds all
18 stages in order with their formations, scenery, bosses and two bonus rides. crystalCanyonPreset is materially
different through the same API: a different view, a hero who only flies inside a narrow canyon with three hits a
life, a slower five-shot gun, three new stages (a hydra, a gem-smashing bonus ride and a shielded warden that
launches drones), shootable homing orbs, no creeping score, an extra life every 1,000,000 and a game that loops.
A quick look
A game from the preset, stepped with input and drawn through the world it stands on:
const SR = game.scalerRunner;
const g = SR.createRunner(SR.spaceHarrierPreset({ difficulty: "normal", startStage: 1 }));
g.start();
g.tick(dt, { x, y, fire, target }); // stick in -1..1 (y up) or an absolute target from the pointer
for (const e of g.drain()) present(e); // destroyed, boss-start, stage-clear, bonus-tally, player-hit ...
for (const b of g.camera.bands(g.stageDef.ground)) drawBand(b);
for (const s of g.field.view(g.camera, { shadows: true })) drawSprite(s);
Works with
scaled-depth— required: the camera, the ground surfaces, the paths, the scenery streams and the field.typography— for the score, lives and banners.jet-combat— for a banking jet with lock-on missiles on the same world.wire-cockpitandrail-route— for a first-person crosshair on a camera path instead.
Good to know
- The classic preset's speeds, paths, timings, fire rates and several other values are estimates from frames and descriptions, not tables taken from the original; a few of its features (a dark section, stacking enemies, the attract demo, high-score initials and continues) are not reproduced.
- After a fatal hit the hero tumbles for 2.4 seconds and gets up with 2.5 seconds of invulnerability, rather than the original's undocumented sequence.
- The game steps in whole sixtieths of a second.
- Bounds: at most 999 stages, 64 members a wave, 64 units a squad and 64 segments a serpent, and snapshots restore only into a game made from the same config.






