What it does
createHoles is the mechanic. A digger strikes the diggable cell beside and below its feet, one stroke at a time, and
after enough strokes the hole is open. It cannot dig under a ladder, a bar, an item or another body, and a body arriving
over the site early in a stroke cancels it. Open holes close after a time through stages, crushing whatever is inside,
or stay open until filled by hand. An enemy that falls into an open hole is held there, its feet on the hole's floor or
its head level with the girder so others can walk over it, and after a while it climbs out, perhaps filling the hole
behind it. Enough hits on a held enemy knock it through the floor, and when it lands the pack reports how many floors it
fell. Holes can be deadly for the player, and trapped heads can serve as floor.
createDigTrapGame adds the rules of a whole game. Levels are authored as rows of text through a legend, with markers
for the player, enemies and items, and cells tagged to reveal a hidden ladder once every item is taken. Around them sit
lives, scoring, treasure that enemies carry off, an exit, enemy schedules, an oxygen timer, kill rules by floors fallen
and three difficulties.
The pack never moves a body itself except to hold a prisoner. Running, ladders, bars and falling come from
platform-walker, the level from platform-map, and enemy pursuit from platform-enemies, so holes work beside
everything else those packs do. It runs headless in fixed 1/60 s steps and reports an event for every stroke, trap,
escape, crush, knock and landing.
Features
- Dig strokes — any number of strokes to open a hole, a stroke time, cancellation by an arrival over the site, and digging from the ground, a ladder or a bar, never while falling.
- Holes that close or stay — timed closing in stages that crush, or holes that stay until filled stroke by stroke.
- Trapping — enemies held feet-down or head-flush, harmless while held, climbing out after a hold time.
- Knock-through falls — hits that drop a prisoner through the floor, with the floors fallen and anything it landed on reported.
- Heads as floor — none, trapped prisoners only, or every trappable body, so runners can stand on enemies.
- Treasure and exits — items scored on touch, carried and dropped by enemies, hidden ladders revealed when all are taken and an exit row to reach.
- Enemy schedules — counts per level, release over time, respawns on a set row and promotions to tougher kinds.
- Oxygen timer — per-level supply and a bonus per second left.
- Two presets and an importer —
lodeRunnerPresetwith eight bundled levels andparseLodeRunnerLevelfor the classic text format at any size, andspacePanicPresetwith eight stages. - Three difficulties —
digTrapDifficultyscales enemy speed, hold time, hole time, oxygen, enemy count and promotions.
Good for
- Treasure-collecting dig-and-trap puzzles in the style of Lode Runner, with gold, guards, ladders, bars and a hidden exit ladder.
- Girder-digging arcade games in the style of Space Panic, where enemies must fall a set number of floors.
- Your own levels in the classic format, imported as text at any size.
- A platformer whose hero digs pits for chasing monsters, using
createHolesalone in an existing walker world. - Trap-to-cross puzzles, where an enemy must be held in a hole so the player can walk over its head.
- Other platform layouts with dig traps, such as girders and conveyors, by marking the floors diggable.
Make it yours
The hole rules are a plain object: stroke count and time, the cancellation window, how long a hole stays open, its
closing stages, fill strokes, knock strokes and what counts as a hit, hold time, climb speed, whether escape fills the
hole, how prisoners sink, which tags are trapped or killed, and what counts as floor. The game definition adds the
levels and legend, objective (collect or clear), enemy kinds and counts, release schedule, respawn row, pace by
count, kill thresholds and score tables, contact window, scoring, lives, extra lives, oxygen and difficulty. Every
preset field can be replaced.
The two presets show how far apart the configurations go. One digs in a single stroke, refills on a timer that crushes, holds guards feet-down and lets everyone stand on them, with gold carried off and a hidden ladder to a top-row exit. The other takes four strokes to dig, leaves holes open until filled, holds aliens head-flush, needs three hits to knock one through, and kills an alien that falls far enough for its kind or lands on another, against an oxygen clock. The rules also mix: the second game with the first's crushing refills is one configuration.
A quick look
Dig traps added to your own walker world, with a crushed enemy removed:
const holes = game.digTrap.createHoles({ world, enemies, targets: ['player'], rules: {
strokes: 2, strokeTime: 0.2, interruptBefore: 0, open: 4, closing: [0.5], fillStrokes: 0, knockStrokes: 0, knockWith: 'either',
hold: 3, climbSpeed: 30, escapeFills: false, sink: 'bottom', trapTags: ['enemy'], deadlyTags: [], heads: 'trapped' } });
holes.dig('player', 1); // from your input handler
for (const e of holes.drain()) if (e.kind === 'crushed') enemies.remove(e.id, 'crushed');
Works with
platform-map— required: diggable cells, the dig and refill edits, and hidden ladders.platform-walker— required: the player and every enemy, and heads offered as floor.platform-enemies— required by the game: pursuit, and suspending and resuming prisoners.platform-movers— optional lifts and belts beside the holes.excavationanddig-combat— for top-down tunnelling through earth instead.platformer-2d— for physics traversal courses.
Good to know
- Holes are single cells; deeper pits are dug stroke by stroke from inside.
- A held prisoner ignores gravity until released.
- At most 256 enemies a level, one hole per cell and one prisoner per hole.
- A lost life restarts the level from its authored rows.
- Positions are continuous rather than on the originals' step grid, and many of the second preset's numbers are estimates from footage and descriptions.






