1Data-driven biomes
A biome isn't code: it's data. One plain object describes the sky, the terrain palette, the celestial body, the parallax ridges and the ambient particle effect. The renderer reads the sheet and paints the rest.
{
id: 'desert',
sky: [0xf6b66b, 0xfde9c8], // sky gradient
terrain: { fill: 0xd9a441, edge: 0xf0cd7a, dark: 0x9c6f25 },
mountains: [0xd8a566, 0xc28a4a], // two parallax ridges
ambient: 'sand', ambientColor: 0xe9cf9a, // background particles
roughness: 1.25, // drives the terrain ruggedness
}
Four biomes — Meadow 🌳, Desert 🏜️, Tundra ❄️, Volcano 🌋 — share one engine. To add a fifth, you add an object, not a code path.
roughness rides along in the biome: the same number drives the terrain generator and the wind feel, keeping each place coherent.2One renderer-agnostic module for two surfaces
The TV draws with Phaser; the phone controller draws a small preview on a plain canvas. To keep the cannon, the charge tint and the windsock identical on both, the shared maths lives in src/render/visuals.js — pure functions that return numbers, never touching either renderer.
// barrel: cool steel at low power, glowing red at full charge export function barrelColor(power) { const t = powerRatio(power); const base = { r: 0xd7, g: 0xdd, b: 0xe8 }; const hot = { r: 0xff, g: 0x3b, b: 0x2f }; // …g, b the same }
This module knows neither Phaser nor the DOM: it returns numbers (colours, geometry points). Each view draws them with its own technology — one shared source of truth for the look.
shade(), craterRimColor() and computeWindsock(). None imports Phaser. That's the rule: anything shared between renderers must stay renderer-agnostic — it computes geometry and colours, and each surface draws them its own way.3Textures generated at runtime
The project ships no image files. The particle sprites — spark, smoke, flash, cloud — are drawn once at boot into off-screen textures, then tinted and blended at runtime. Asset-free, yet fully styleable.
let g = make(); g.fillStyle(0xffffff, 1); g.fillCircle(5, 5, 5); g.generateTexture('spark', 10, 10); // reused, tinted, for every biome
No audio files either. Every effect is built at runtime from oscillators and filtered noise through the Web Audio API, in src/systems/Sfx.js. A cannon shot, for instance, is a short low-passed noise crack plus a descending sine thump.
const osc = ctx.createOscillator(); osc.type = 'sine'; osc.frequency.setValueAtTime(160, now); osc.frequency.exponentialRampToValueAtTime(50, now + 0.25); // it descends
Sfx.unlock() runs on the first tap/click — without it, the first sounds would silently never play.4Depth, parallax & quality tiers
The fake 3D depth is just two Phaser properties per layer: depth (draw order) and scrollFactor (how much it follows the camera). Far ridges scroll slowly, the foreground scrolls fully — and the inter-round camera pan reveals continuous parallax.
this.ridge(far, GAME_HEIGHT * 0.62, 70, DEPTH.mountainFar, 0.25); this.ridge(near, GAME_HEIGHT * 0.72, 50, DEPTH.mountainNear, 0.45);
Smart TVs and weak browsers can choke on the full particle/parallax load. So the host measures its own frame rate for a short window at startup and records a quality tier. The renderer then scales effects to match.
const fps = 1000 / avg; const tier = fps < LITE_FPS_THRESHOLD ? 'lite' : 'full'; scene.registry.set('quality', tier); // the renderer reads this