What it does
The pack is the rules layer on top of two others. rail-route flies the player along a rail, casts the aim ray,
flies enemy shots and keeps the shields; vector-wire holds the line models and projects them. This pack decides
what each stage contains and how it scores. You create a cockpit from a definition, step it with the aim, the fire
button and a secondary button, and read events (score, laser, explode, fireball, shield-hit, speech,
tally, wave-complete, game-over) and the state. cockpitScene projects stars, targets, shots, the surface, the
trench and the explosions into SceneLine segments for a vector renderer.
A wave is built by your definition's waves function, which returns its stages. The built-in stages cover a full
mission. A dogfight keeps a few ship slots filled from a queue, each ship flying a data choreography, firing in
windows that tighten with the wave, with an indestructible flagship that spins away when hit and an assist that swings
the view toward the current target. An approach flies in to the station. A surface is a wrapping field of
laser towers with shootable tops worth more each time, bunkers and their guns, ending in a rolling dive. A trench
is a grid of panels, catwalks and wall guns down to an exhaust port, with a bonus for hitting it without firing
before it appears, and a harder rerun after a miss. Probots, walkers with eyes to shoot, tow cables and a
bonus for flying between their legs, and an asteroid field complete a second kind of mission.
The session runs around the stages: the select screen where you shoot a target to choose your starting wave and bonus, shields with a short immunity after each hit, kill quotas that pay points or a letter and multiply the stage's later kills, a difficulty ramp with Easy, Normal and Arcade presets, the end-of-wave explosion and the tally. It runs headless at a fixed step and is deterministic for a seed and an input sequence.
Features
- Stages as modules —
dogfight,approach,surface,trench,probots,walkersandasteroids, each a data definition, and your own types throughstageTypesorregisterStage. - Scripted dogfights — ship slots refilled from a queue, choreographies of turns, climbs and jinks, fire windows by difficulty, kinds that cannot be destroyed, and a timer or a quota.
- A tower-covered surface — towers with shootable tops and rising values, a bonus for every top, bunkers, guns, collision with the towers, speed under the player's control, and the dive at the end.
- A trench run — bands of panels, catwalks and wall guns, an exhaust port to hit, a bonus for holding fire, and a harder rerun after a miss.
- Walkers and asteroids — walkers shot in the eye or tripped with a tow cable, a bonus for flying between their legs, probes and their transmissions, and an asteroid field that costs shields on contact.
- Quotas and letters — a stage's kill quota pays points or a letter of a word, multiplies later kills, and a complete word pays a bonus and a spell of immunity.
- Shields and the session — shields with immunity windows and bonus shields, a select screen with start bonuses,
the explosion and the tally, and
snapshotandrestore. - Difficulty —
difficultyPreset('easy' | 'normal' | 'arcade')scales the ramp, the fire rate and the speed of enemy shots. - Two presets —
starWarsPresetandempirePreset, in the style of the 1983 and 1985 vector arcade games, with their tables and stage builders exposed for reuse. - A scene to draw —
cockpitSceneanddefaultModelsturn the state into coloured line segments in a seven-colour palette.
Good for
- Vector cockpit shooters in the style of the 1983 Star Wars arcade game: a dogfight, the surface and the trench.
- Ice-planet missions with probes, walkers and an asteroid field, in the style of The Empire Strikes Back arcade game.
- Custom space missions that mix stages, such as a trench run with probes over it, or a dogfight with a kill quota and letters.
- Retro line-art shooters where the look is glowing vectors and the aim is a crosshair into the screen.
- Short arcade sessions with a select screen, a tally and a difficulty that climbs wave by wave.
Make it yours
A game is a CockpitDef: the waves function that returns each wave's stages, the select screen's choices or a
fixed startWave, the shields, bonus shields and their cap, the immunity window, the difficulty, the tally, the phase
timings, the rail camera, the gun's timing, letters for quotas, your own stageTypes, the seed and a maximum wave.
Every stage's definition is data too: the dogfight's duration, slots, queue, scripts and fire table; the surface's
layout, laps, speeds and tower values; the trench's slots, length, speed and bonus. The presets take options of their
own, such as shields, dogfight length, ships at once, surface laps, trench length, quotas, tow cables, the swarm stage's
length and the asteroid field's length and density.
Two very different missions: a trench-only run, made by filtering the classic preset's stages, where every wave is a dash down the trench to the port; and a mission of your own that sets a custom stage module, such as a timed survival leg, between two of the ice-planet stages. A third mixes the presets: probes over the station's trench, or a dogfight scored with the second preset's kill quota and letters.
A quick look
A cockpit from the classic preset on Normal, stepped with the pointer's aim and drawn as lines:
const WC = game.wireCockpit;
const cockpit = WC.createCockpit(WC.starWarsPreset({ difficulty: WC.difficultyPreset('normal'), shields: 6 }));
cockpit.begin(); // the select screen
cockpit.step({ aim: cockpit.rail.screenToAim(x, y, view), fire, secondary });
for (const e of cockpit.drain()) { /* score, laser, explode, shield-hit, tally, wave-complete, game-over … */ }
const lines = WC.cockpitScene(cockpit, { w, h, oy, time });
Works with
rail-route— required: the flight, aim rays, enemy shots and shields.vector-wire— required: the line models and their projection.vector-2d,vector-fontandpost-bloom— to draw the scene's segments, the HUD and the glow.polygon-rail— for a rail shooter drawn with polygons rather than lines.scaled-depth,scaler-runnerandjet-combat— for sprite-scaling shooters.
Good to know
- It is rules and data only: no drawing, sound or speech, though speech lines arrive as events. It is for one player.
- The ship choreography, surface fields and trench patterns are authored or generated from documented behaviour and counts, not copied from the original machines, and the trench always leaves a way through.
- Hits are 3D rays against spheres and boxes rather than the originals' screen-space shapes.
- The HUD and the cockpit frame are your game's to draw; the scene helper covers the world.






