Back to Rail Game
SOURCE / PINNED RELEASE

Made of little things.

Rail Game

Release
ccdd5b913413…
Author-recorded commit
ddf0122b6acc…
License
LICENSE
Author’s source reference
nostr://npub1n8ga89w8h6tvwamxusfyzexw8gjy84yxu9rxgnmk955cxtml4ujswzxydd/wss%3A%2F%2Fgit.napplet.soy%2F/n-91ec90c6fdf

Archive hash verified: dad7b678e25f96a3…. The source-to-build association is the author’s claim; it has not been independently rebuilt.

docs/game-spec.md
# Rail game prototype

nappletType: rail-game
purpose: Steer a growing, automatically firing squad down a straight track and defeat eight stage bosses.
NAPs used: storage (optional progress), theme (optional palette), config (optional motion and sound settings).
requires: none
optional domains and fallbacks: storage → session-only records; theme → explicit dark palette; config → built-in defaults.
SDK helpers: storage.getItem/setItem, themeGet/themeOnChanged, config.registerSchema/subscribe.
data flow: Simulation runs locally; validated best scores and unlocked stages use the scoped `rail-progress-v1` storage key. No identity is needed.
relay escape hatches: none
config schema: soundEnabled, reducedMotion
interop: none
density: 13px compact HUD; 44px touch targets for game controls.
tiers: tiny → resize notice; compact → full-height track and abbreviated HUD; regular → expanded HUD; wide → wider world, more scenery, full controls hint; short-height → reduced overlays.
minimum size: 240×280, because approaching targets, the squad and touch controls need distinct readable space. Below this floor, pause and show “Needs 240 × 280 to play. Enlarge this pane.”
theme: optional; fallback background #101d25, foreground #e9f2f2, primary #78edbb. Runtime colors repaint the complete canvas and UI.
states: ready scene + start action; playing; paused; stage complete + next stage; defeated + retry; campaign complete + replay. Persistence errors stay inline and never block play.

## Play

- Move continuously with A/D, arrow keys, drag on the track, or hold the on-screen arrow buttons. Firing is automatic.
- Start with twelve soldiers. Recruitment gates add 24–95 soldiers. Green ×2 and ×3 gates multiply the current squad, capped at 250.
- Amber damage and violet rapid-fire pickups upgrade shots; a blue shield absorbs one collision.
- Coral enemies can be shot. Striped barriers cannot; steer around them. Either costs soldiers on contact.
- Each stage has a deterministic, learnable sequence of gates, multi-row enemy formations and barriers, then a tougher moving boss with dodgeable spreads of shots.
- Stages unlock in order. A new stage starts with a fresh squad and upgrades so retries are fair. Records and unlocks persist when storage is available.
- Pause on lost focus, hidden document, or undersized frame; never resume without player intent.
- Canvas uses projected geometric boxes and particles; no external assets or 3D dependencies. Reduced motion removes decorative movement, shake and particles while retaining essential gameplay motion.

## Eight-stage campaign and camera

The eight stages span 900–2160 meters, taking 90–160 seconds before the boss.
Two smaller flanking platoons join the opening wave.
Four to eleven 180-meter combat sectors rotate lanes and alternate single/double
barriers, crossfire waves and reinforcement choices. Enemy formations contain
30–45 individuals in five columns; later sectors add more health. The final straight has recruits,
damage and rapid fire to prepare for the boss. Boss spreads stop at nine shots so
later stages retain escape routes. The campaign picker uses two rows of four
compact numbered buttons, with locked status in accessible labels and disabled states.

Every soldier renders and fires independently: normal volleys every 0.22 seconds,
rapid volleys every 0.09 seconds. Up to 250 soldiers fit in fourteen columns.
Only nearby living targets participate in projectile collisions; cosmetic
particles have a fixed budget. The foreground is lifted slightly to fit the deeper
formation above the touch controls. No new NAP requirements or dependencies.

The camera is behind and to the left of the straight stage. An off-center
perspective places the distant track left of the nearby track, producing a gentle
diagonal without bending the rails or rotating the HUD. Pointer movement uses the
same camera scale as drawing. Narrow frames retain both side lanes and the full
largest formation. These changes need no new NAP domains, assets or dependencies.

## Verification

Run upstream guidance, type-check, build and conformance; test the simulation's collisions, upgrades, pause, loss, boss victory and campaign progression. Exercise the real soyLI iframe at 200×160, 320×560, 900×600 and 2400×1200 in both themes, plus touch portrait/landscape viewports. Report actual-device coverage separately.