---
name: html-game-generator
description: Build a complete, polished, production-quality browser game inside a single self-contained HTML file using only vanilla HTML, CSS and JavaScript — no frameworks, no libraries, no external assets. Use this skill whenever the user asks for a game, a playable demo, a prototype, an interactive toy, or anything "inspired by" an existing title — platformers, tower defense, RTS, racing, RPGs, physics games, city builders, simulations, card games, survival, idle/incremental, puzzle and arcade games all qualify. Trigger it even when the user never says "HTML" or "single file", and even for requests that sound small ("make me a snake game", "something to kill five minutes"), because the default deliverable is always one finished .html file with menus, art, sound, particles and save support built in. Also use it when the user wants an existing single-file game extended, rebalanced, or polished.
---
# HTML Game Generator
Turn a game idea into one HTML file the user can double-click and play — finished, not prototyped.
## Purpose
The deliverable is a complete game: title screen, tutorial or control hints, core loop, difficulty progression, win/lose states, sound, particles, persistence, and a restart path. It runs offline from the filesystem with zero setup, zero build step, zero network requests, and zero dependencies.
The failure mode worth naming up front is **the tech demo**: a grey rectangle that moves, one enemy, no menu, no sound, `// TODO: add more levels`. That is not the deliverable. A user who asks for a tower defense game wants to play tower defense for twenty minutes, not to see that tower defense is possible. Every choice in this skill points at that difference.
The second failure mode is **scope collapse under pressure** — quietly dropping the third enemy type or the upgrade shop because the file was getting long. Length is not the constraint. If something has to give, simplify how things *look*, never what the player can *do*.
## Capabilities
Determine which systems the game needs and build them. The request rarely names them; infer from the genre and the described experience.
- **Physics** — AABB and swept collision, gravity and drag, impulse resolution, verlet ropes/soft bodies, projectile ballistics, restitution and friction.
- **AI** — finite state machines, steering behaviours (seek/flee/wander/separate), flocking, aggro and threat, difficulty curves, opponent decks and build orders, utility scoring.
- **Pathfinding** — A* on grids, flow fields for many units, line-of-sight and simple navmesh, local avoidance.
- **Procedural generation** — value noise, cellular automata caves, room-and-corridor dungeons, wave-function-collapse-style tiling, weighted loot and encounter tables, seeded RNG for reproducibility.
- **Combat** — hitboxes/hurtboxes, i-frames, damage types and resistances, knockback, status effects, cooldowns, crits.
- **Economy and progression** — currencies, costs and rewards, XP curves, upgrade trees, unlocks, prestige loops.
- **Inventory and crafting** — grid or list inventories, stacking, equipment slots, recipes, containers.
- **Rendering** — Canvas 2D, layered canvases, camera with follow/lerp/shake, parallax, tilemaps with culling, procedural sprite generation, lighting and fog of war, DOM/CSS for UI.
- **Particles and effects** — pooled emitters, screen shake, hit-stop, flashes, trails, weather.
- **Audio** — full Web Audio synthesis: SFX, adaptive music, mixing, ducking.
- **UI** — menus, HUD, modals, tooltips, drag-and-drop, minimaps, tech trees, settings, pause.
- **Animation** — tweening with easing, sprite and skeletal-style animation, state-driven transitions.
- **Persistence** — LocalStorage saves with versioning and migration, autosave, settings, high scores.
Implementations for all of these live in `references/engine-patterns.md`. Read it before writing the engine layer of any non-trivial game.
## Output Rules
These are hard requirements. Violating them means the deliverable doesn't work when the user opens it.
1. **One file.** A single `.html` document containing everything. No companion `.js`, `.css`, `.json`, image or audio files.
2. **Vanilla only.** HTML, CSS, JavaScript. Nothing else.
3. **No libraries, ever.** Not React, Vue, Angular, Svelte, Phaser, PixiJS, Matter.js, Planck, Three.js, Babylon, p5.js, Howler, Tone.js, Tailwind, Bootstrap, jQuery, GSAP, lodash, or anything else. No `