Depthfield
Depthfield is a survivor for one player. The soldier’s weapons fire on their own while the player moves and dashes through swarms on a neon field. Each level deals upgrade cards to pick from. Elites arrive at one and two minutes, and the boss lands at three; beating it completes the run and puts it on the board.
Run it
Section titled “Run it”The following commands write a copy of Depthfield, install it and play it:
npx @spawnite/cli create my-depthfield --template depthfieldcd my-depthfieldpnpm installpnpm devThe same source is in the examples repository. The game’s numbers are in units of 1/42 of a metre, as the canvas game it started from measured, so its 210 units a second walk is 5 m/s.
The run
Section titled “The run”The game opens on a lobby: the soldier large on a neon platform, with the picks beside it and one Play button. The lobby takes a look, a starting weapon and a stage, and rolls a class for the run, which it shows with its four stats. Play starts the run on the field at once: a look or a weapon never picked falls back to Grove and Bullet. A run is played under the player’s name in the app, or as Runner without one. Leaving a run, from the pause menu or an end screen, comes back to the lobby; the restart button starts a new run on the same picks without it. The picks stay in the player’s save, so a later visit opens on them:
- Classes. Soldier, Prophet, Vanguard, Skirmisher, Sentinel and Artillerist, each a share of the base health, speed, fire rate and range. The Prophet, at one run in twenty, has 150% of all four.
- Looks. Grove, Ember, Tide, Violet and Gilt turn the soldier round the colour wheel. Prismatic cycles every hue and unlocks at 100 kills across runs.
- Weapons. Bullet, Laser, Boomerang, Shards, Nova and Mine; Zap unlocks after one finished run. A weapon joins the loadout at levels 3, 5 and 7, up to four.
- Stages. Neon Grid, Ember Foundry and Prism Vault, each with its own layout, colours, floor hazard and mix of enemies. Ember Foundry unlocks when a run on Neon Grid reaches the boss at three minutes, and Prism Vault when the boss falls on Ember Foundry. A locked stage shows what opens it.
W, A, S and D or the arrows move, Space dashes 180 units the way the soldier faces, then waits four seconds. P pauses, M opens the field notes, and 1 to 4 pick a card. On a phone, a stick moves and a tap dashes. On a touch screen or a window narrower than 640 pixels, the run shows only a chip with the clock and the level, the minimap, the soldier’s health over its head, and a pause button; the pause menu holds the restart and the field notes.
Enemies come in from a ring round the soldier. Grunts come first, and each stage lets the other kinds in on its own schedule:
| Stage | Layout | Hazard | Enemies |
|---|---|---|---|
| Neon Grid | The source’s fifteen boxes. | None. | Runners at 30 seconds, tanks at 60, shooters at 90 and summoners at 120. |
| Ember Foundry | A ring of furnace blocks round the centre, open on each axis, and smaller blocks further out. | Ten vents in the floor. Each glows for 1.2 seconds, then erupts for 1.5, once every 7 seconds, the vents spread over the cycle. An eruption burns the soldier and every enemy standing in it, every half second. | Tanks at 20 seconds, runners at 30 at under half the others’ share, shooters at 45 and summoners at 120. Spawns come 15% slower. |
| Prism Vault | Four columns of tall pillars along the field, which form lanes. | A beam wall to wall. Every 12 seconds its line appears 9.5 metres before the soldier for 1.5 seconds, then sweeps across the field at 10 metres a second, hurting the soldier and every enemy it crosses. A dash through it dodges it. | Runners at 10 seconds, summoners at 60, tanks at 75 and shooters at 100. Spawns come 15% faster. |
A hazard first stirs four seconds into a run. Its hits on the soldier go through the same rule as an enemy’s, so the threat grows them; its damage to enemies does not count toward the run’s. An elite spawns at one minute and a crimson elite at two; each telegraphs its lanes, rifts and shears on the ground before it strikes. A loot runner flees across the field and drops two levels of experience. At three minutes the field clears and the boss lands. Health reaching zero ends the run on the death screen, so the scene’s <CharacterSpawn> turns the engine’s respawn off.
The threat keeps up with the soldier. Every enemy but the loot runner spawns with its health times the threat, and every hit an enemy lands on the soldier is times a gentler share of it. The threat grows with the clock, with no cap, and with each level past the fifth, so a soldier whose upgrades compound still meets a dangerous field. src/rules/threat.ts holds the curve and its numbers.
When the boss falls, the victory screen offers to keep going. Keep going plays on, endless, on the same field: the waves return and spawn ever closer together, an elite comes every 45 seconds, gold and crimson in turn, and the boss lands again every three minutes, stronger each time by the threat. The clock counts on beside an Endless tag. The soldier’s fall ends an endless run as a win, and the board keeps its whole length. The board ranks won runs first, the longest first, then every run by its damage, and names each run’s stage.
Upgrades
Section titled “Upgrades”A level-up deals four cards. Weapon cards upgrade a weapon the soldier owns; every third deal is passive, for experience, drops, speed and recovery. Each card rolls a rarity, Normal, Rare, Epic, Legendary or Prismatic, which scales what it gives. The cards stand side by side over the dimmed field, each framed and lit by its rarity, with the weapon’s icon, the gain in large type and the weapon’s level change; on a phone they stand two by two. A reroll deals four more, three a run, and Reroll+ lifts each card a tier, once a run; both buttons sit under the cards. The Prismatic card adds the echo, a second soldier who fires beside the first.
What the save keeps
Section titled “What the save keeps”The player’s save keeps what carries between runs: the kills across runs toward Prismatic, the runs finished toward Zap, the stages opened, the ten best runs on the board, each with its stage, and the lobby’s last picks. They live in one persisted store, progress, in src/store/progress.ts, so a signed-in player finds them on any device. They are a store rather than a defineSave declaration because the lobby reads them outside the world, as Saving progress says. The store’s merge reads each stored state with its schema, so a state the schema refuses refuses the load and is never written over. A field added later, such as the stages opened, takes a default, so a save written before it still loads. A run in progress is not saved: a reload goes back to the lobby, so the save does not include random.
The look
Section titled “The look”The camera stands 24 m off and 69 degrees down, as the source’s projection did, with a 54-degree lens. The floor, the grid, the walls and the props are the stage’s colours drawn past the engine’s tone mapping: Neon Grid keeps the source’s navy floor ruled in cyan and magenta, Ember Foundry has a dark red-brown floor ruled in amber and orange under magma-orange rims, and Prism Vault a deep violet floor ruled in gold and white under gold rims. The void round the arena is the stage’s sky, drawn by screen height, the source’s violet-to-navy on Neon Grid. A vent’s glow and a beam’s line are drawn as the elites’ telegraphs are: a circle that fills, and a line that brightens. The engine grows no grass at any quality level here, since its blades would poke through the arena’s floor. Bloom picks out only colours lifted past white: the rims, the walls, shots, rings, orbs and sparks, a hit’s flash and a muzzle’s.
The soldier, the swarm, the elites, the boss and the guns are Meshy models, made from concept art for this game and kept in the asset library. The field has no lights, so a matcap shades every model, lit from the upper left, with a bright rim. Each model leans 35 degrees back from the camera, so the steep view sees it standing rather than foreshortened.
- The soldier is the engine’s Player wearing the rigged model, whose legs blend idle, walk and run by its speed. Each shot turns it to the shot until no weapon has fired for 0.6 s, and each shot of the gun in its hands plays one shot of the shooting clip on its upper body, while its legs turn toward its step. The rules ask for each clip, so a room would agree on them. Each shot of the gun in its hands kicks it: the body jolts back and squashes, the chest rocks back, and the gun slides back and lifts, harder for the nova and the mine than for the pulse. Grove keeps its armour’s painted mint, and every other look turns the armour to that look’s hue.
- The guns. Each weapon has a gun of its own. By default the soldier holds the first weapon of its loadout at its chest, low at rest and raised as it fires, with both hands on the grips; in a roll the gun rides its right hand. The others float round it, each turning to its own shots. A shot flashes at the gun’s muzzle and lights the floor.
- Its moves. A dash rolls the soldier forward and leaves glowing copies of its pose and a streak on the floor. A level-up swells it inside a ring of light before the cards open, and a hit flashes it white, knocks it back and shakes the camera.
- The swarm. Each kind is one instanced model, tinted in the kind’s colour, facing the soldier and waddling as it walks. A hit squashes it and lights it white. A killed enemy flashes white, squashes flat and bursts into sparks of its colour. The sparks are one effect on the engine’s Particles, built in code, with each burst naming its colour and count.
- The elites and the boss are rigged models that walk, run as they rush, and turn along their dash. The boss sinks into the floor, turning, as it bursts apart.
The lobby shows the soldier model idling on its platform in the look picked, three-quarters on to the camera and turning to face it at each pick. It holds the gun of the weapon picked at its chest in both hands, as the field’s soldier does, and a weapon pick raises the gun and plays a shot on its arms. A stage pick repaints the platform, the grid and the sky in that stage’s colours, and the lobby’s screen takes the stage’s neon as its accent. On a phone the picks are a sheet along the bottom, one tab at a time, with Play at its foot.
In development, the devtools’ Look panel switches to the source’s pixel sprite and flat figures, and between variants of each effect: the lean, the spare guns held in the hands instead, the muzzle, the dash, a tumble or a shatter for the death, the glow’s strength, the rims and the shake. The choices stay in the browser.
How the soldier is drawn
Section titled “How the soldier is drawn”The soldier stands on the engine’s own parts: its <CharacterSpawn> model blends its legs by speed, aimAt turns it to each shot, playClip plays its shooting clip on the upper body and its roll and fall on the whole, and useAfterPose lays the game’s lean, kick and grip over the pose. The look scales the soldier to its height itself. The lobby hides the engine’s copy of the soldier and draws a dressed copy in the pose useAfterPose hands it.