# ๐Ÿ™๏ธ PolyCity โ€” 3D City Builder **PolyCity** is a full-featured, free, open-source city-building simulation that runs entirely in your browser. Zone districts, wire up power, keep citizens happy, fight fires, balance the budget โ€” and grow a tiny island outpost into a glittering megalopolis. Built with **Three.js + Vite**, zero runtime dependencies beyond the engine, procedural graphics (no asset downloads), and a simulation modeled on the classics. ![gameplay](docs/screenshot.png) ## โœจ Features | | | |---|---| | ๐Ÿ—บ๏ธ **Procedural islands** | Every new map is unique โ€” winding rivers, beaches, forests | | ๐Ÿ˜๏ธ **RCI zoning** | Residential / commercial / industrial with demand-driven growth | | โšก **Power grid** | Coal, solar & wind plants; brownouts when demand exceeds supply; wind turbines get +50 % on the coast | | ๐Ÿ“ˆ **Land value & upgrades** | Parks, plazas, services and waterfronts raise land value; buildings grow through 3 density tiers | | ๐Ÿš“ **City services** | Police, fire stations, hospitals and schools shape happiness and value | | ๐Ÿ”ฅ **Disasters** | Pollution-driven fires spread and are contained by fire coverage; mature cities face tornadoes that flatten whole streets (toggle in settings) | | ๐Ÿ’ฐ **Budget & taxes** | Live tax slider, itemized income/upkeep ledger, debt warnings | | ๐Ÿš— **Traffic** | Animated cars flow along your road network | | ๐ŸŒ— **Day/night cycle** | Windows light up as the sun sets | | ๐ŸŽฏ **Goals & milestones** | From *Outpost* to *Megalopolis*, with an onboarding quest list | | ๐Ÿ’พ **Saves** | Autosave, 3 manual slots, JSON export/import | | ๐Ÿ“ฑ **Touch support** | Paint with one finger, pinch-zoom, two-finger rotate | | ๐Ÿ”Œ **PWA** | Installable, offline-capable via service worker | ## ๐ŸŽฎ Controls | Action | Input | |---|---| | Use tool / paint | **Left-drag** or one finger | | Orbit camera | **Right-drag** or two fingers | | Pan | **Middle-drag**, or `WASD` / arrow keys (`Shift` = faster) | | Zoom | Mouse wheel / pinch | | Pause ยท speed | `Space` ยท `1` `2` `3` | | Tools | `Q` inspect ยท `B` bulldoze ยท `R` road ยท `Z/X/C` zones | | Close / cancel | `Esc` ยท Help: `H` | ### How to play in 30 seconds 1. Drag an **L-shaped road** from the coast inland. 2. Paint **homes** beside it, then some **shops** and **industry**. 3. Drop a **coal plant** anywhere โ€” power is a city-wide grid. 4. Press โ–ถโ–ถ and watch the neighborhood fill in. 5. Add police/fire/parks to push land value past the upgrade thresholds. ## ๐Ÿš€ Run it locally ```bash pnpm install pnpm dev # dev server โ†’ http://localhost:5173 ``` ## ๐Ÿ“ฆ Production build ```bash pnpm build # outputs static site to dist/ pnpm preview # serve dist/ locally ``` The build is fully static and relative-path based โ€” drop `dist/` on any host. ## ๐ŸŒ Publish it **GitHub Pages** โ€” this repo ships `.github/workflows/deploy.yml`; push to `main` and enable Pages (*Settings โ†’ Pages โ†’ Source: GitHub Actions*). **Netlify / Vercel / Cloudflare Pages** โ€” import the repo, build command `pnpm build`, publish directory `dist`. A ready-made [`netlify.toml`](netlify.toml) is included. **itch.io** โ€” zip the contents of `dist/` (keep `index.html` at the zip root), upload as an HTML5 game, check *sharedarraybuffer is not needed* and any resolution; the game auto-fits. ## ๐Ÿงช Tests ```bash node tests/engine.mjs # 40-assertion simulation suite (pure Node) node tests/soak.mjs # 40-year economy/growth/power soak test node tests/smoke.mjs # headless-browser end-to-end run node tests/capture.mjs # renders promo screenshots into shots/ ``` ## ๐Ÿ› ๏ธ Tech notes - One shared `MeshStandardMaterial` + instanced meshes draw the entire city in a handful of draw calls; geometry is merged & vertex-colored at load time. - Simulation runs on typed arrays (64ร—64 tiles) with monthly ticks decoupled from rendering; speeds pause / 1ร— / 2ร— / 3ร—. - Adaptive resolution keeps frame times sane on weak GPUs. - All audio is synthesized WebAudio โ€” no assets, no tracking, no network calls. ## License [MIT](LICENSE) โ€” build, remix, ship it. ๐Ÿ—๏ธ