What it does
The field is a grid of cells, some holding mushrooms, with a player area along the bottom. A chain moves one cell at a time, each body segment stepping into the cell the one ahead has just left, so a chain is always one continuous path. The head moves sideways while the way is clear and turns down a row at a mushroom, the edge or another chain; a poisoned mushroom can send it straight to the bottom instead. In the player area it bounces between the bottom and the top of the area, tails can break off as new heads, and single heads come in from the sides once a chain reaches the bottom.
Shooting a segment scores it, leaves a mushroom in its cell and splits the chain: the front keeps going, and the rear becomes a new chain led by the segment behind, every segment keeping its identity and path. That one rule is what turns a single enemy into a screen of heads weaving through mushrooms the player made.
Around the chains sit the rest of the game. Mushrooms take several shots, can be poisoned or turned to flowers, and are restored one by one after a death. Hazards are data: each has a motion (drop, spider, cross, zigzag, bounce or crawl), a hit box, a speed ramped by score, hit points, scores by distance from the gun, effects on the cells it passes and on the game when it dies, and a spawn schedule. DDT-style bombs release a cloud that destroys what it touches and multiplies its score; insect raids pay more for each kill in a row; the field can scroll and evolve. The gun takes a stick and a trackball or pointer, and fires one shot at a time, again the moment the last one lands.
Features
- Splitting chains — shoot a segment and the chain splits, the segment behind leading a new chain at the same speed and progress.
- Turning and diving — heads turn down at obstacles and edges, dive through poisoned mushrooms, and bounce in the player area.
- Tails and replacement heads — tails can break off at the bottom, and new heads arrive from the sides on a timer, up to a cap.
- A mushroom field — multi-hit mushrooms, poison, flowers that stop shots, and restoration after each death.
- Hazards as data — fleas, spiders, scorpions, bees, earwigs, inchworms, dragonflies, mosquitoes, beetles or your own, each with motion, effects, scores and spawn rules.
- Bombs and raids — clouds that clear cells and enemies for a multiplied score, and raids with rising points per kill.
- Scrolling and evolution — the field can scroll up or down, creep during a wave, and evolve by Game-of-Life rules.
- A wave cycle — formations of a chain length and extra heads, palettes per wave, and all-fast waves from a score.
- Stick and trackball — digital movement plus a nudge in pixels for a trackball or pointer.
- Deterministic — fixed steps, a seed, events to drain and snapshots to save.
Good for
- Classic segmented-enemy shooters with a mushroom field, fleas, spiders and scorpions, in the style of Centipede.
- Busier sequels with bombs, insect raids, flowers and a scrolling field, in the style of Millipede.
- Centipede-likes of your own, with a different field size, player area, chain length or hazard set.
- Trackball or touch arcade games, where the gun follows a pointer as well as keys.
- Puzzle variants with no hazards at all, only chains and a field.
Make it yours
The factory takes no options; everything is the definition passed to createSegmentedShooter. centipedePreset
takes the field's columns and rows, the player area, the chain length, lives, the extra-life score, mushroom hits,
field density, difficulty, a seed and the hazards; millipedePreset adds bombs and raids. Any field of the returned
config can then be replaced: cell size, chain speeds and scores, every turning and splitting rule, replacement-head
timing, the wave cycle, the gun's size and speed, the trackball limit, shot speed, restoration, hazards, raids and
bombs. segmentWaves builds the classic shorter-chain, more-heads cycle for any chain length.
Two materially different configurations: a 20 by 24 field with an 8-segment chain, a 5-row player area, only a spider and a flea, and a two-formation cycle; and a 16 by 20 field with a 6-segment chain and a 4-row player area, where tails never break off, no replacement heads arrive, kills leave no mushrooms and segments pass each other.
A quick look
A game from a preset, stepped with keys and a trackball nudge:
const ss = game.segmentedShooter;
const g = ss.createSegmentedShooter(ss.centipedePreset()); // or ss.millipedePreset()
g.tick(dt, { move: { x, y }, nudge: { x: dx, y: dy }, fire }); // fixed 60 Hz frames inside
for (const e of g.drain()) present(e); // segment-killed, chain-split, hazard-killed, player-hit, wave-start...
const s = g.state; // cells, chains, hazards, clouds, player, shot, score, lives, wave
g.reset(startWave, seed); // a new game, optionally at a later wave and on a new field
Works with
world-screenandtypography— a fixed screen to draw on, and the score and lives.scoreboard— a high-score table and initials entry, which this pack leaves out.marching-fleetorflight-formation— for formation shooters instead.wave-arena,maze-roomsorasteroid-field— for free-roaming shooters instead.
Good to know
- One player. Two-player alternation, the high-score table, attract mode and sound are left to your game.
- Fields are limited to a million cells and 10,000 live segments, and a chain moves at most four cells a frame.
- The first preset follows its original design notes closely but approximates the starting field, hit boxes, input speeds and the spider's moves; the sequel's preset is a faithful core with tuned spawn rates, raid sizes and speeds.
- Snapshots hold the state but not the configuration, so restore into a game built from the same definition. It is 2D only.






