A mining and upgrade game: drive the pod off the outpost pad, drill down, bring the ore back up and sell it, then spend the credits on eight upgrade lines and go deeper. Five strata over 840 metres, each harder, darker and hotter than the last, with gas pockets, falling boulders and flowing lava on the way, ten buried artifacts with permanent perks, three contracts at a time, and the Hollow Heart, a boss behind a sealed gate at the bottom.
How it's built
- Rules and drawing are separate. Everything that decides the game lives in
core/ as plain TypeScript with no Phaser imports: world generation, the pod's physics and drilling, hazards, the economy, contracts, artifacts, the boss and saves. Phaser only draws the state and plays effects for the events the simulation reports. 28 Vitest tests run the rules without a browser: generation per biome, digging, hardness, fall damage, thrust and fuel, the fuel needed to get home, selling, towing, gas blasts, falling boulders, lava flow, heat, the boss fight, the gate and save round trips. - A fixed 60 Hz simulation. The pod moves in tile units with gravity, thrust, ground and air control, and collides against the tile grid one axis at a time, in sub-steps so a fast fall never tunnels through a floor. Rendering interpolates between steps, so it stays smooth at any frame rate.
- Digging is a short state, not a collision trick. Down drills the tile under the pod's centre, sideways needs a short push against a wall, and the pod eases into the tile over the dig time (hardness × 0.28 s, faster with each drill level). Rock harder than the drill allows is refused with a message that names the drill you need.
- A seeded world. 36 × 430 tiles from one seed: biome borders bent by noise, caves from fractal noise, ore in veins from per-ore noise fields with biome thresholds, gas and boulders sprinkled in, lava poured into the magma caves, relic ruins in the Hollow and a hand-built boss chamber. The same seed always builds the same world. Saves keep the seed plus the dug-out map, run-length encoded (a few kilobytes).
- Hazards run near the pod only. Boulders with nothing under them wobble, then fall as objects and land as tiles again; lava moves cell by cell and keeps its volume; a drilled gas pocket lights a short fuse and blasts a radius, setting off other pockets nearby. All of this runs in a window of rows around the pod, so the cost does not grow with the map.
- Progression. Eight upgrade lines with five levels each (drill, fuel tank, hull, cargo bay, engine, radiator, lamp, radar), four kinds of supplies (blast charge, repair kit, fuel cell, recall beacon), contracts whose rewards scale with your depth, and artifacts that change the numbers (sell prices, fuel use, fall damage, heat, dig speed). The Relic Key opens the gate to the boss; after the boss, "Keep digging" starts a new world with ore worth 50% more and every upgrade kept.
- The boss. Four pylons beam a shield onto the Heart while it fires aimed volleys of shards; volleys grow and quicken as pylons fall. Once exposed it is drilled like a tile that never breaks, blast charges hurt it, and at half health it shakes boulders from the ceiling.
- Drawing. Phaser 4 (WebGL). Every texture is painted with Canvas 2D at start-up, so there are no image files: a tile sheet with three variants per rock, ore overlays, rim tiles picked by a four-neighbour mask (lit top edges, shaded sides), back walls per biome and grass on the surface, plus the pod (body, three tread frames, four drill frames, flames), the outpost, the sky and hills, the Heart and the particles. The map is four tile layers (back wall, rock, ore, rim); digging repaints a cell and its neighbours, never the whole map.
- Light. Below the surface one large darkness texture with a soft hole follows the pod; the hole is the lamp, so a lamp upgrade simply scales it. Glowing tiles (amethyst, ruby, starsteel, lava, relics, artifacts) get pooled additive glow sprites above the darkness, and the radar draws pulsing pings for ore beyond the lamp.
- Portal seam. The game talks to a games portal only through one interface (loading progress, gameplay start and stop, mid-game and rewarded ad breaks, cloud save and load, leaderboards, happy time). Here it is a mock: cloud saves go to their own storage key with latency (the newer of the local and the cloud save wins on load), the leaderboards mix your best with simulated players, and ad breaks are a labelled overlay. A free tow when you run out of fuel is the rewarded break; a mid-game break is offered at most every third dock visit after five minutes of play. The pause menu shows a log of every portal call.
- Input. Keyboard (arrows or WASD, 1 to 4 for supplies), an on-screen pad on touch screens with multitouch so you can steer and thrust at once, and a gamepad through Phaser's gamepad plugin. Phaser's own keyboard and pointer input are off; React owns input and merges the three sources each frame.
- Guidance without a tutorial screen. The fuel gauge carries a notch for the fuel needed to fly straight home (from the simulation's own thrust numbers, tested so that exactly that much gets you up), and a one-time warning says to turn back when the tank gets close to it. On the first dive, short tips appear only while they apply ("drive off the pad", "head home to sell") and vanish once you have done it; after the first sale the dock points to the Workshop.
- Tiles that do not look like tiles. Rock is a flat colour with soft mottling that wraps across edges (no per-tile gradient), six variants per rock, random mirroring and a slow noise-driven tint per cell, so the ground reads as one mass. Open space sits on a much darker back wall. Lava gets a bright surface skin where air is above it and steps through its variants so pools churn.
- Everything readable is HTML. The HUD, dock, dialogs, banners and toasts are HTML styled as the outpost's painted steel; a polite live region carries the messages. The canvas is hidden from screen readers.
- Reduced motion. No camera shake, flashes, lamp flicker, bobbing, landing squash or drifting clouds, far fewer particles, and banners fade instead of moving. The game plays the same.
- Performance. The canvas is sized in device pixels (ratio capped at 2, 1 on the low tier) and scaled down with CSS, so it stays sharp. The game loop sleeps while the canvas is off screen or the tab is hidden. Particle emitters and glow, ping, boulder, shard and text sprites are pooled.
- Sound is generated with Web Audio (no files) and is off until turned on: a drill hum whose pitch follows the rock's hardness, thruster rumble, ore chimes pitched by value, a till for selling, blasts, alarms, the boss's volleys and a slow pad soundtrack that drops and darkens with each stratum. Audio is muted while the tab is hidden and during ad breaks.
- Balance by bot.
core/bot.ts plays like a careful first-time player (one straight shaft, ore one or two cells to each side, home when the tank holds little more than the trip back, buys what unblocks it first) and core/balance.test.ts runs it: a quick check always (seed 7 must reach the Crystal Caves within 30 game minutes), and with BALANCE=1 a report over 12 worlds × 120 game minutes written to tmp/balance.txt. The bot exposed three design problems that are now fixed: a drop down your own shaft could wreck the pod (falls are now capped at 16 t/s with damage above 10.5 t/s), a fallen boulder overhead could trap it (thrust against rock drills upward), and a broke pilot could get stuck at the dock (a free top-up to 50% fuel and 40% hull). It also found a physics bug: a fall that ended exactly flush with the floor registered no impact and dealt no damage. - Balance numbers (12 worlds, medians, game minutes). First run: Shale 1.8, Crystal Caves 8.9, Magma Belt 15.6, deepest 430 m, 445 counted stalls (almost all a bot fault: a dive that did not beat the old record counted as a stall, and the bot fell back into its old shaft on the way to a new one), one world stuck at 82 m. After fixing the bot: Shale 3.0, Crystal Caves 8.8, Magma Belt 17.0, deepest 482 m, 47 tows, 0 wrecks, longest gap between purchases 7.5 min (worst 10.6). No world reached 800 m in 120 minutes: the straight-shaft bot turns home at every gas pocket or lava pool in the Magma Belt, where a player steers around them, so the economy was left unchanged rather than tuned to the bot's weakest skill.