diff --git a/.claude/agents/flood-crew.md b/.claude/agents/flood-crew.md index effb8597..0f513602 100644 --- a/.claude/agents/flood-crew.md +++ b/.claude/agents/flood-crew.md @@ -7,11 +7,11 @@ You are the specialist for **Flood Crew**, a game on Arjun's site (ascoding11.gi ## What it is -Flood Crew (Back Room; first built as Ebbwork, and the folder, the `ebbwork:v1` save key and the names in the code keep that name), a single-player first-person flood-drainage game: each job is a flooded place, and you work out why it flooded and get it dry (three.js r187 from the site's own build with its r128 layer, then `../autores.js`; no Firebase, no rooms, no stats.js, no ads). It is our own design: the name, the six places, the tools, the prices and the text are ours. **Files:** `index.html` (the page and its styles), `game.js` (drawing, controls, sound, HUD and menus), `core.js` (everything that is not drawing, with no DOM and no three.js in it, so `node` can load it: `require('./core.js')` gives `{EWSim, EW, EWMaps}`), `es.js` (its Spanish for `../lang.js`) and `preview.jpg`. +Flood Crew (Back Room; first built as Ebbwork, and the folder, the `ebbwork:v1` save key and the names in the code keep that name), a single-player first-person flood-drainage game: each job is a flooded place, and you work out why it flooded and get it dry (three.js r187 from the site's own build with its r128 layer, then `../autores.js`; no Firebase, no rooms, no stats.js, no ads). It is our own design: the name, the six places, the tools, the prices and the text are ours. ## Where it lives -- Folder: `e63334287a3deaa3/ebbwork/`: `core.js`, `es.js`, `game.js`, `index.html`, `preview.jpg` +- Folder: `e63334287a3deaa3/ebbwork/`: `core.js`, `es.js`, `game.js`, `index.html`, `models.js`, `preview.jpg` - Docs: the bullet for `e63334287a3deaa3/ebbwork/` in `README.md` (and the indented points under it). This is the source of truth for how the game works and stores data; read it in full before changing anything, and update it when you change behaviour, storage or file layout. - Phone page: a row in `GROUPS` in `e63334287a3deaa3/m/index.html` and thumbnail `e63334287a3deaa3/m/thumbs/ebbwork.jpg`. diff --git a/README.md b/README.md index f9dd8528..5727a599 100644 --- a/README.md +++ b/README.md @@ -67,7 +67,7 @@ Personal site hosted with GitHub Pages at **https://ascoding11.github.io**, the - `e63334287a3deaa3/flickerwood/`: Flickerwood (Back Room), an 8-bit maze chase for one player (one file, one canvas, Web Audio, no libraries, no Firebase except stats.js). Glim, a firefly, gathers every speck of pollen in a moonlit hedge maze (a glade) while four night critters come out of the hollow stump in the middle and chase its light. It is our own take on the maze-chase genre: the name, theme, characters, mazes, art, sounds, words and numbers are all ours, and only the genre's ideas are used. **The four critters** never find a path: at the middle of every tile each one picks the open way (never straight back) whose next tile is nearest, in a straight line, to the tile it wants (`target()`), and all of its character is in that tile. Swoop the bat wants Glim's tile; Gulp the frog wants the tile 3 ahead of the way Glim faces (`AHEAD`); Tangle the spider wants the point on the far side of Glim from Swoop (twice Glim's tile minus Swoop's); Dither the moth wants Glim while more than 5 tiles away (`NEAR`) and its own corner once closer. They take turns at two moods on a clock: **roost** (each heads for its own corner: Swoop top right, Gulp top left, Tangle bottom right, Dither bottom left) and **hunt**; every time the mood changes they all turn straight round, which is the tell. Glim is faster than they are in an empty corridor and a little slower while eating, turns can be pressed early and are remembered until the next gap, a turn started up to 4 pixels before the middle of a tile cuts the corner and gains those pixels (`CUT`; up to 3 pixels late it is still taken, `LATE`), and a reverse is taken anywhere. A **moonbloom** (four a glade) dazzles the critters: they turn round, go pale, slow to 60% and mostly run away, and touching one sends it home as a puff of dust for 100, 250, 500 then 1000 (`CATCH`); they flicker for the last 2 seconds, and a caught one rests 1.2 s in the stump and comes back out as itself. **Tunnels** at the edges (`~` tiles) wrap round and slow critters to 55%. A **find** (dewdrop, acorn, clover, toadstool, bluebell, feather, snail shell, moonstone, one kind a glade) shows under the stump for 9 s when 35% and again when 70% of the glade is eaten, worth 200 plus 100 a glade up to 1000. Our own twists: **Dash** (0.32 s at 2.1 times speed, then 6 s to recharge, shown as a meter) and the **chain** (each speck eaten within 1 s of the last carries it on; every 12 raises the multiplier on specks, up to 5 times). Specks are 5, moonblooms 30, clearing a glade 100 times its number up to 1000 plus 300 if no life was lost in it; 3 lives, one more at 6,000 and every 15,000 after, 5 at most. **Rules** live between `// ==RULES==` and `// ==END RULES==`: no page, clock, sound or `Math.random` in there, so the same seed and presses always give the same game (`create(seed)`, `startGame(g)`, `step(g, 1/120)`, `turn(g, d)` with d 0 right, 1 down, 2 left, 3 up, and `dash(g)`; what should be heard or shown goes into `g.ev` as words, and eaten tiles into `g.gone`). Positions in the rules are maze pixels; the page adds the score bar above. Glim and the critters are a tile, a direction and how far along it they are (`c, r, dir, off`), so they can never leave a path; they touch when both gaps are under 7 pixels (`HIT`, smaller than the sprites). **Glades** are the five `MAZES` at the top of the rules, drawn by hand as 23 rows of 21 letters (12-pixel tiles): `#` hedge, `.` pollen, `o` moonbloom, `-` path, `~` tunnel, `HHH` the stump with `G` its gate above the middle, `P` Glim's start, `B` the find, space outside the glade. Hedge Court is a full rectangle with a tunnel across the middle, Lily Pond has its corners cut off and tunnels top to bottom, Bramble Wheel is not mirrored (its bottom half is its top half turned half round) and has two tunnels, Mossy Ruin has tunnels both ways through the middle of each edge, and Moth Hollow is an hourglass with none; glade 6 is Hedge Court again, quicker. A new or changed glade must stay: every path one tile wide (no open 2 × 2), no dead ends, all joined up, a border tile that is a path matched on the opposite border, the start at least 8 steps from the gate with a way left and right (Glim sets off left), one moonbloom in each quarter, nothing but hedge next to the outside. A script checked all of that for the five glades when they were made (it is not in the repo), so check again by hand if you change one. **Tuning** is `tune(level)` and the constants at the top of the rules: Glim 66 pixels a second plus 1.3 a glade; critters 70% of that plus 3 points a glade (97% at glade 10); the dazzle 8 s less 0.67 s a glade, never under 2; roosts of 7, 7, 5 and 4 s (less 0.55 s a glade, never under 1.5) between hunts of 13, 15 and 18 s (plus 1.2 s a glade), then hunting for good; Gulp leaves the stump after 3 s, Tangle after 12 s or 30 specks, Dither after 28 s or 90 specks, all sooner glade by glade; from glade 3 Swoop speeds up 6% when 20% of the pollen is left and 12% under 8%, and keeps hunting through roosts; nothing tightens after glade 10 (`TOP_LEVEL`). Glade 1 is meant to be cleared by a first-time player: a test bot that only heads for the nearest pollen and runs when something is three tiles away clears it nearly every time. **Drawing**: the game is a 252 × 300 picture (a 14-pixel score bar, the 252 × 276 maze, a 10-pixel strip for spare lives, the dash meter and finds). `layout()` shows it at a whole number of device pixels per game pixel, so pixels stay square and sharp, and tries three places for it, biggest picture first: under the top bar with the key hint, under the bar without the hint, and between the bar's title and buttons (so a 1366 × 768 laptop with a short browser window still gets 2 ×); only when a whole number would be 1 is it drawn at 2 and shrunk smoothly to fit. Never size the canvas with CSS percentages or `vh`. Sprites are rows of letters turned into small canvases once (`bake`; Glim is drawn facing right and turned for the other three ways; two frames each; the dazzled look is the same shapes in two pale tones); the hedges, stump and tunnel marks are drawn once per glade (`mazeL`, and a lit copy `flashL` for the blink when a glade is cleared), the pollen sits on its own layer and each speck is wiped from it as it is eaten, the score bar is redrawn only when something on it changes, and words use a 5 × 5 pixel alphabet drawn in code (capitals, digits and `+ - : ! .` only). The loop runs the rules in fixed steps of 1/120 s and draws between steps. It pauses when the tab is hidden or the window loses focus. **Sound** is made in the page: square, triangle and noise blips in `SFX`, and a 16-bar tune of our own in A minor in `TUNE` (notes as numbers), booked a tenth of a second ahead on the audio clock; while a moonbloom is on, a quicker bright figure plays instead. Nobody has listened to it yet, so the loudness and the tune want a check by ear. **Saved in the browser only**: `flickerwood-best` (score), `flickerwood-glade` (furthest glade), `flickerwood-mute` (in try/catch), keys under `keybinds:flickerwood`. Stats hook: `max('score', score)` and `max('glade', glade reached)` when a glade is cleared and at game over (the Leaderboards show best score). Controls: arrows or WASD turn, Space or Shift dashes, P, Enter or Esc pause, M sound, all rebindable under KEYS. On touch screens (`body.touch`): swipe anywhere to turn (keep sliding to turn again without lifting), tap the screen to dash, or use the d-pad with a DASH button either side of it under the screen (pad on the left and DASH on the right when the phone is sideways). How to play, with a picture of each character, sits beside the screen when there is room, otherwise behind the ? button. A test hook (`window.__fw`) exists only when `navigator.webdriver` is set. It has Spanish: its words are in `flickerwood/es.js` (lang.js), with a Language switch in How to play; the canvas words are chosen to need no accents (the 5×5 pixel font has none), and glade and critter names stay English. **The Wardrobe** (captains only for now, like the other games' hidden cosmetics): 28 looks for Glim in `flickerwood/wardrobe.js`, listed in `cosmetics.js` under `GAMES.flickerwood` (14 kits, 7 hats, 2 face pieces and 5 trails: sports kits, a tin firefly, pirates, suits and more, all seen from above). The page fetches `wardrobe.js` and `../cosmetics.js` only when `wardrobeOn()` is true (`FLICKERWOOD_PUBLIC`, the one line that opens it to everyone; a site captain through `captains.js`; or `?wardrobe=1` on localhost or in an automated browser), and then a hanger button appears in the top bar; for everyone else `WR` stays null and Glim is drawn exactly as before. Looks only: a look swaps `SP.glim` for pictures of the same 16 × 16 size (so the spare Glims on the score bar wear it too), no kit recolours the glowing yellow tail or the halo (what tells Glim from the critters), and trails are drawn under the critters and Glim, fade in 0.4 s and are never small yellow dots that could pass for pollen. Opening it pauses a game in progress. What is worn is saved in this browser as `flickerwood-look` (`{k, h, f, t}`, item numbers, 0 for none); nothing is sent anywhere. The words are in `es.js`. - `e63334287a3deaa3/lanternhold/`: Lanternhold (Back Room), a co-op tower defense game for 1 to 4 players (one file, three.js r128 with `../autores.js`, `../netsmooth.js` for teammates' pointers, Web Audio, Firebase Realtime Database rooms under `rooms/lh-`, same project and rules as Rumble Karts; invite links go through the home page as `#lh-`; no Quick match, rooms hold up to 4). The name, the Gloom, the towers, the maps, the art and the sounds are all our own. The Gloom walks a road across a floating island (a 20 × 12 grid of 2 m tiles, `GW`/`GH`/`T`) to the lantern; each one that gets there costs lives (`lv` in `EN`: 1, 2 for Shellbacks and Splitblobs, 15 for the boss). Towers go on grass tiles only (not road, scenery or the lantern). **Rules** are plain data and pure functions near the top of the script, the same in every browser, so a client can work out wave previews and enemy health without asking: `MAPS` (Meadow Bend, one long road; Twin Fords, two roads that meet; Whorl Garden, a spiral, whose flyers come from their own pink gate, `fly`, so they don't skip almost the whole map), `DIFFS` (Easy, Normal, Hard: health factor, lives 30/20/12, starting gold 720/620/540, bounty factor and seconds between waves), `EN` (Gloomling; Skitter, fast; Shellback, armour 7 taken off every hit, at least a quarter always goes through; Duskmoth, flies straight at the lantern; Splitblob, splits into three Bloblets; Mender, heals the Gloom near it 5% a second; Gloomwarden, the boss on every 10th wave, armoured, slow, and calls two Skitters every 5 s), `TW` (Bolt Spire, quick single shots, two at once at level 3; Thumper, lobbed blasts that hurt groups, ground only; Frost Bell, rings out to slow and chip everything near it, bosses half as much; Spark Coil, lightning that jumps between enemies; Sky Lance, flyers only, splash on nearby flyers; Sun Lens, a long beam that ignores armour), each with three levels (`lv`: range, damage, seconds between shots and the upgrade's cost) and a target mode (First, Last, Strong, Close). Selling gives back 70% of what went into the tower (`SELL`). `waveDef(w, map)` builds wave w from a seeded random pool (new kinds join at waves 2, 4, 5, 6 and 8, and the wave a kind first appears always has a group of it), `hpScale` makes them tougher each wave and faster still after wave 30. Survive 30 waves (`CAMPAIGN`) to win; then Keep going is endless mode. Gold: every kill's bounty and every wave's bonus (25 + 5 a wave) is split evenly between the players (`income`), each player spends their own share, and the team list has +50 to give gold to a teammate. Sending a wave before its countdown ends pays 2 gold per second left. Speed 1×, 2× or 3× (`sp`, anyone can change it). Only whoever built a tower can sell it (anyone can once they've left); anyone can upgrade or retarget it. `simStep(S, dt)` runs the game at a fixed 30 steps a second in solo, behind the menu (a demo game, `attract`) and on the online host; `act(S, uid, a)` applies one action (`b` build, `u` upgrade, `s` sell, `m` target mode, `w` send the wave, `f` speed, `g` give gold, `c` continue into endless) and returns '' or what went wrong. **Online:** each player writes only their own node `rooms/lh-/players/`: `n` name, `c` colour, `x`/`z` where their pointer is on the board (drawn on the others' screens as a ring and a name tag from a short history, NetSmooth), `h` (always 0), `ts` (server time), `j` (when they joined), and `ac`, their last 10 actions as JSON, each with a rising number `i` and the game number `g`. The host is whoever has the highest `he` with a published state, else whoever joined first (`Net.elect`); it runs the game, takes each player's new actions (`takeActs`, at most once each, by `i`, and only for the current game), and publishes the whole state as JSON in its own node's `rs` about 5 times a second (`encodeRS`: phase, wave, lives, gold per player, towers, enemies, Thumper shells in the air and the last shots, so clients can draw them). Clients rebuild the game from it (`decodeRS`, which checks every value) and move the Gloom on between snapshots from its speed, easing towards the host's numbers. If the host leaves, the next player picks up the last snapshot and carries on (`he` goes up by one), and a tab in the background keeps the host's game running once a second. The host picks the map and difficulty in the room's lobby and presses Start; anyone joining later gets a share of gold (the average, at most 250). Nodes are removed on leave and onDisconnect. **Saved in this browser** (localStorage, all `lanternhold:`): `name`, `color`, `map`, `diff`, `gfx` (Pretty, with shadows, or Fast; Fast is the default on touch screens), `sound`, `room` (the last room code) and `best::`, the best wave held. **stats.js:** `max('wave', waves held)` and `add('bosses', n)`; the Leaderboards show Most waves held and Gloomwardens beaten. **Touch:** shown only on touch screens (`body.touch`): tap a tower button, tap a tile to see the tower there, tap it again to build; drag to move the board, pinch to zoom. The camera fits the board into the space the HUD leaves (`fitCam`, `measureHud`), and on an upright phone the wave box becomes a row under the top bar and the dock gets compact. **Drawing:** the island, scenery and lantern are merged meshes with vertex colours; enemies, health bars, shots and rings are instanced meshes (their colour buffers are made at full size in `whiteColors`, because three r128's `setColorAt` sizes the buffer from the mesh's current count); particles are one Points draw. Automated browsers get a test hook, `window.__lh`. It has Spanish: its words, tower names and descriptions are in `lanternhold/es.js` (lang.js), with a Language switch on the menu and the pause screen; map names and the Gloom's names stay English, and nothing translated is sent to the room. **Wardrobe (hidden: captains only for now).** `LH_PUBLIC = false` and `wardOn()` (captains.js's `may(false, 'wardrobe', 'lh-wardrobe')`; `?wardrobe=1` for tests on localhost or in an automated browser) decide whether the menu shows a Wardrobe button under the colour swatches; for everyone else `lanternhold/wardrobe.js` is never fetched and the game is exactly as before, unless a teammate wears something, in which case it is fetched to draw them. It has 30 items in four slots, numbered as in `../cosmetics.js` (`lh-…`): 12 tower banners (a small flag on a pole at the back-left of every tower that player builds, seen by the whole team: sports pennants, a gear, a pirate flag with an eye-patched skull, a ship's wheel, pinstripes, a crown; baked into the tower's base mesh through `towerParts`' new `ban` argument, so a tower is still the same draw calls and its shape, owner band and level gems are untouched), 9 lanterns (the lantern's stand and cage on the captain's own screen only: `lanternGeo()` is the usual one, and `world.core.body`'s geometry is swapped; the flame, halo and light stay where they are and the same size), 5 flame colours (the flame's and halo's colour on the captain's own screen only; the point light is not recoloured, the low-lives flicker and the red flash are kept) and 4 build bursts (in place of the usual puff in `fxBuild` when that player builds or upgrades, seen by everyone, from the same particle pool). Saved in this browser as `lanternhold:wardrobe` (`'banner.lantern.flame.burst'`); online, a player's own node carries `cz: 'banner.burst'` (written with `Net.upd`) only while one of those is worn. Older pages ignore `cz`, `rs` and the actions are unchanged, and a page draws the usual look for numbers it doesn't know. The test hook `window.__lh` adds `WD` (with `wear(slot, n)`), `wardOn`, `wdLoad`, `wearOf`, `towerViews`, `towerMesh`, `wx`, `wz` and `world`. Its words and item names are in `lanternhold/es.js`. - `e63334287a3deaa3/windrow/`: Leaf Sweep (Back Room; first called Windrow, and the folder, the `WR` name in the code, the save key `windrow:v1`, `keybinds:windrow` and the stats name keep that), a calm single-player first-person game about clearing autumn leaves out of five walled gardens (three.js: the site's own r187 build, `/lib/three/r187/three.min.js` with its r128 layer, then `../autores.js`; no Firebase and no rooms, except `stats.js` for play time; no ads). The page is `index.html` (markup, styles, HUD and menus) plus five plain scripts in `js/`, loaded in this order: `world.js` (the areas, the collision grid and everything that stands still), `leaves.js` (the leaf simulation and its drawing), `audio.js` (every sound, made in code), `models.js` (gloves, sack, rake, blower, finder beams) and `game.js` (player, tools, money, HUD, menus, saving, the frame loop); `es.js` is its Spanish. Everything is drawn and textured in code; nothing is downloaded. **The start.** A new player stands on the doorstep of a garden house in the Front Yard (8 x 7 m of buried lawn with a stone path, one bin, low walls and a closed gate) with only their hands. It is a sixth area, `WR.AREAS[5]` (`WR.YARD`), added after the first five so the numbers in older saves keep their meaning; `WR.ORDER` is the order areas are listed in. Its leaves lie 1.5 times thicker (`dense`), and clearing it to 100% opens the gate to Gatehouse Court by itself, free. The screen shows a crosshair, the sack and the acorns, and one line of instruction at the bottom middle (`hintText` in `game.js`: hold to gather; sack full, empty it in the bin, with a bouncing marker over the bin; spend acorns in the shed; bought the rake; the gate is open), one at a time, each gone when done. Everything else appears when it first matters (`hudStatic`): percent cleared and the shed after the first sack is emptied, the tool bar with a second tool and only with tools owned, garden names, the Gardens tab and map, gate signs and the finder button once the court is open. The shed lists the sack, hands and rake at first and the rest as they become useful (`shedShows`). `state.seen` remembers which lines have been shown; a save that already has the court open skips them all. A scripted player clears the yard in about 100 game-seconds, with the first upgrade after the first sack and the rake after the third. **The garden** is flat, about 61 x 53 m, on one grid of 0.25 m cells (`WR.CELL`, 248 x 216; the plan in `world.js` is written at full size and every position is then multiplied by `WR.S` = 0.8, so the gardens are small and the leaves lie thick): `solid` blocks the player and the leaves, `gtype` is the surface (lawn, paving, decking, gravel: how far a leaf slides), `inlet` marks mulch-chute cells, `areaOf` says which garden a cell belongs to. The five big gardens are the first entries of `WR.AREAS` in `world.js` (Gatehouse Court, Orchard Walk, Lily Terrace, Glasshouse Row, Maze Lawn) with their gate cost, the garden that must be half cleared first, the bonus and the reward for finishing (sprint, kneel, higher jump, chutes that draw leaves in, a gold rake); bins, chutes, gates, trees, hedges and benches are lists just under it, and `WR.buildGrid` turns them into the grid, so moving a prop means editing its list only. Its last step, `seal()`, proves every leaf can be cleared: with all gates open it finds the cells a player can stand in, and any free cell with no standing spot within 2 m in a clear line (a slot behind a bench, say) is made solid, so neither leaves nor feet can get into it (5 cells with the present props; about 18 ms at load). **Leaves** are real objects, never removed by pointing: each has a place, a speed and a tumble, and leaves the garden only by being carried to a compost bin in the sack or by reaching a mulch chute. To stay cheap, resting leaves are asleep and cost nothing; each leaf sits in one grid cell (a linked list per cell), so a tool only visits the cells it reaches; and leaves do not collide one with another: a cell is a stack (each extra leaf rests 1.4 cm higher), a cell with 26 leaves turns sliding leaves away (40 for falling ones, about 56 cm) and a leaf near the top of a stack 5 taller than a neighbour slides off onto it. A leaf never moves more than 0.22 m in a step and its new place is rounded to what the arrays hold before the wall test, so nothing gets through or into a wall. That is what makes heaps against walls and rows in front of the rake. `Leaves.blow` is the blower (a cone; force falls with distance and with angle off the middle, 13 rays stop it at walls, leaves low in a heap are sheltered), `rake` carries the leaves under the head along with it, `scoop` sends the nearest leaves in a ring to the sack (they need a clear line from the player, except a garden's last 6 leaves, so none can be stranded behind a bench), `kick` is walking through them and `pull` the Draught grates reward. A leaf is two triangles: a flat card with one of four leaf shapes cut out of it (alpha test) by a 256 px atlas drawn in the page, tinted per leaf. They are drawn as instanced meshes, one per garden and leaf shape (20 draw calls); each mesh keeps its leaves in the order of the 4 m tile they started in and only the tiles where something moved are sent to the graphics card each frame. On top is one see-through 'litter' sheet whose opacity comes from a texture with one pixel per cell, so cleared ground looks clean about a second after its leaves go. **How many leaves** is the quality setting, in leaves per square metre of open ground (`WR.QUALITY`): Low 14 (27,600 leaves in the whole garden), Medium 24 (47,300), High 40 (78,800); Medium and High have a real shadow map from the low sun, drawn once (nothing that casts a shadow moves, except a gate opening), and Low has soft dark patches under the trees instead. Colours are written as screen colours and lit in linear light (`WR.lin`, sRGB output, ACES tone mapping), so any new colour or canvas texture must go through `WR.lin` or be marked sRGB. Phones start on Low, computers on Medium. Measured: with a fully upgraded blower sweeping through leaves the simulation costs 0.4 / 0.5 / 0.8 ms a step (1.4 / 3.0 / 2.8 ms at 4x CPU slowdown), with up to 2,800 leaves awake at once; looking across the first garden draws about 78k / 117k / 180k triangles in about 70 draw calls. Not measured: the cost of the cut-out leaves overlapping on a real phone's graphics chip (the test machines have none). `autores.js` lowers the resolution first; if frames stay slow for 8 s after that and the player never chose a setting, the game drops one leaf tier itself and says so. An area's leaves are worth the same in total at every tier (`units`; fewer leaves are each worth more), and the sack and the hands are measured in quality-free units too (an area's `leaves` number is its size in sack units; `Leaves.fill` is what one leaf takes), so progress and prices do not depend on the setting. Changing the setting scatters the leaves that are left again and keeps each garden's percent. **Looks and feedback.** `world.js` builds the house (door, lit windows, shutters, roof, chimney), trees with a crown of rounded masses shaded light above and dark below, walls with piers and caps, slatted benches, the fountain and a painted sky with cloud and a sun glow. `models.js` has rounded gloves on sleeves: open hands and the sack, a fist on the blower's handle, and two fists and forearms that follow the rake's handle in the garden itself. The blower shows wind streaks and lifts and tumbles leaves; landing from a jump throws leaves up and out, with a burst of loose leaves and a sound when it is a real heap; a rake stroke ends with a thump and a puff of crumbs; emptying the sack pours leaves into the bin; buying something pulses the HUD; 100% is a warm flash, falling leaves and a fanfare. **Tools and money.** Hands and sack, a rake (a stroke reaches out lifted, then drags back along the ground, so it pulls) and a blower (it pushes). Acorns come from leaves: at a bin when the sack is emptied (20% more for a full sack) or at once at a chute. `UP` in `game.js` is the shed (nine upgrades and their prices) and the arrays under it are what each level does; the models in `models.js` change with them. The leaf finder (F, or by itself when under 3% of a garden is left) lights the 8 nearest leaves of the garden you are standing in, and the journal map draws a dot for every leaf on the ground. **Saved data:** one localStorage key, `windrow:v1` (JSON): `acorns`, `earned`, `up` (upgrade levels), `unlocked` and `done` (per garden; six entries now, and a save with five is given the yard, open, as the sixth), `rewards`, `bagUnits` (what is in the sack, per garden) and `bagFill`, `gone` (share of each garden cleared), `tool`, `tut` (no longer used), `seen` (which instructions have been shown), `pos`, `secs`, `binFill`, `set` (look speed, volume, quality, flipped look, whether the player chose the quality), and `leaves` with `leafMul`: for each garden that has been touched, a base64 string of two 16-bit numbers a leaf (centimetres from the corner of the garden; 65535 = gone), about 250 KB at Medium and 420 KB at High once every garden has been disturbed; a leaf saved against a wall is stepped back out of it on loading. An untouched garden saves nothing and is scattered again from its seed. It saves 8 s after a change, on pause, and when the tab is hidden or closed. Keys are rebindable (`keybinds:windrow`); `autores.js` keeps its own scale. It is not in `account-nudge.js`'s KEYS, so it does not follow a Google account to another device, and it has no row in `leaderboard.js` or `miles.js`. **Touch:** `body.touch` is set on the first touch and shows `#touch` (left stick, Use, Jump, Run and Kneel once earned, a context button for bins and gates, and finder, journal and pause top right); the three tool slots at the bottom are tappable on any device. Portrait and landscape have their own positions in the style block; a drag on the view or on the Use button looks around. `WR.test` at the bottom of `game.js` is only for test scripts (start without a click, step the simulation, hold the tool, a simulation benchmark); nothing in the game calls it. -- `e63334287a3deaa3/ebbwork/`: Flood Crew (Back Room; first built as Ebbwork, and the folder, the `ebbwork:v1` save key and the names in the code keep that name), a single-player first-person flood-drainage game: each job is a flooded place, and you work out why it flooded and get it dry (three.js r187 from the site's own build with its r128 layer, then `../autores.js`; no Firebase, no rooms, no stats.js, no ads). It is our own design: the name, the six places, the tools, the prices and the text are ours. **Files:** `index.html` (the page and its styles), `game.js` (drawing, controls, sound, HUD and menus), `core.js` (everything that is not drawing, with no DOM and no three.js in it, so `node` can load it: `require('./core.js')` gives `{EWSim, EW, EWMaps}`), `es.js` (its Spanish for `../lang.js`) and `preview.jpg`. **The water (`EWSim` in `core.js`):** a grid of 0.5 m cells, each with a ground height `g`, a barrier height `bar` laid on top, a depth `d` (kept in 64-bit numbers: with 32-bit ones a slow seep into a deep cell rounded away and volume drifted) and a flow through its right and bottom edge (`fx`, `fy`). Every step (1/30 s, fixed) each edge's flow speeds up by the difference in water surface across it and slows by friction (`fric`, `damp`), no cell may give more than it holds (flows out of a cell are scaled down together), and depths change by what flowed, so volume is conserved exactly: water only appears through `add()` and leaves through `take()`. Walls are `solid` cells. A 3 mm film (`FILM`) never flows, so floors keep real puddles in their dips. Blocks of 8 × 8 cells sleep when nothing in or next to them is changing; an edge into a sleeping block carries nothing and wakes it (leaving that out loses water across the edge). A big pool takes minutes to fall fully asleep because the film keeps creeping, so sleeping saves little while a map is draining; one step with every block awake costs about 1 ms for 128 × 128 cells on a desktop, and the biggest job is 68 × 48. **A job site (`EW.World`):** built from a map's `build(b)` with metres as the unit (x east, z south): `ground`, `shape` and `noise` set heights; `surf` sets the surface type and whether it can be dug; `wall` makes solid blocks (its `kind` is only for drawing); `drain` (a `rate` in m³/s and a `cap`: how much debris blocks it fully), `sinkArea` (water there leaves the map: a ditch or storm channel), `river` (cells held at a level: a stream that both feeds and takes water), `leak` (fed by a `valve` id, or `wrench: true` for a dripping joint), `valve`, `socket`, `litter`, `flood`, `spot` (a note the player gets when they walk near, kept in the journal), `sign`, `station` (the depot's board, bench and van) and `noJob` (cells that don't count). `step(dt)` runs leaks, the river, pumps, drains, sinks, the water and the debris, in that order. Debris floats in more than 5 cm of water, drifts with the current and towards a running drain, strands when the water drops, and blocks a drain by lying within 0.85 m of it (`clog`): a drain's rate is `rate × (0.03 + 0.97 × clear^1.6)`. The job is done (`isDone`) when the water left in the job's cells, not counting the film, is at most 3% of the most there has been (`World.DONE`) and nothing is still coming in. **Tools (each one a function on the world, so a test can call it):** `rake` (push or pull debris), `scoop` and `pour` (the 30-litre bucket), `squeegee` (moves water under 7 cm one cell along), `dig` and `pile` (soft ground only, down to `DIGMAX` 0.64 m; piling uses the spoil you dug), `placeBarrier` (three cells in a row, four directions, `BARH` 0.36 m; refused on drains, ditches and the river), `placePump` / `setHose` / `placeGen` (a pump runs when it is on, has a socket or a live generator within cable reach and has a hose end; water it takes goes to the hose end's cell, so emptying into the same pool does nothing, and it only leaves the map if the hose end is on a sink or the river; a generator standing in more than 14 cm of water stops), `takeDebris` (the sack: removes debris for good), `setValve` and `fixLeak`. **The jobs (`EWMaps`, in order; a job opens when the one before has a star):** Marlow Row (a back yard: a drain buried in leaves and a split pipe with its stop tap round the side; the first play walks a new player through it with `TUT`), Pell Street (three hidden drains, a dripping joint, a paving dip that keeps a puddle), Tanners Field (allotments in a hollow with no drain: a trench through the bank to the ditch; a choked pipe that sits too high to finish the job), Fenny Underpass (a dead sump: pump from a wall socket with the hose over the crest to the storm channel, and a water main valve at the far end), Wharf Cellar (the river seeps in through a doorway: sandbags, then pump up the steps; it is dark, so `sky: 'cellar'` gives a head torch) and Mill Lane (a stream through its bank, a culvert under a raft of debris, a walled garden that needs the pump and the generator, a hollow to trench). `EWMaps.depot` is the depot: not a job, a yard with the job board, the gear bench and the van, and a puddle to try tools on. Each map has `pay`, `par` (the target time in seconds) and `needs` (what the job board suggests bringing, shown only after the player has been there once, so the first visit is for finding out). Stars: one for finishing, a second inside 1.6 × `par`, a third inside `par` with 1.5% or less left; pay is `pay × (0.6 + 0.2 × stars)`, halved when the job has been done before. **Gear** (`GEAR` in the page): tools with `slot: 1` take one of the van's five places (seven with Van racking); the rest are upgrades (more sandbags, long hose, cable reel, second pump, waders, racking). Prices are set so that one-star pay alone affords each next job's tool. **Storage:** localStorage `ebbwork:v1` only: `{v, coins, gear, load, jobs: {: {stars, best, n, seen}}, set: {sens, vol, q, inv}, tut}`; keep `v: 1` and these names working if you change it. Nothing is sent anywhere. **Drawing:** the ground and the water are each one mesh with a vertex at every cell centre and their own shaders (`terrainMat`, `waterMat`): the water's vertices carry its depth and speed, a dry cell beside water takes its neighbours' surface height with a negative depth, and the shader throws away everything shallower than 4 mm, so the shoreline is a smooth line where the surface meets the ground and no squares show. Shallow water is see-through and deep water murky; ripples follow the flow; on High graphics the scene is drawn once more upside down into a small picture (`renderReflection`) so the water mirrors the buildings, and Low reflects the sky only. Graphics: Auto starts High on computers and Low on touch screens and Chromebooks, and steps down to Low for the rest of the visit if frames stay under about 34 a second for nine seconds, after `../autores.js` has had its chance to lower the resolution (`quality`, `autoLow`); it never steps back up by itself. Walls and props are two merged meshes (`Batch`: brickwork and plain), debris is three instanced meshes, and things the player puts down are rebuilt together when they change (`rebuildDyn`). **Sound** is all made in the page with the Web Audio API (`sfx`, `audioTick`): steps and wading, splashes, raking, digging, a gulp when a drain runs shallow, the pump's hum, and a lapping that fades as the place dries. **Touch:** a walk stick on the left (push it right out to run), drag anywhere else to look, and Use, Alt, Jump, Duck, Do and Turn buttons in `#touch`, shown only on touch screens; the tool bar moves to the top there. A slow frame is caught up rather than played in slow motion: up to a quarter of a second, as up to eight water steps and the walking split into 40 ms pieces. **Tests:** `window.__ew` (the world, the player, `start(id)`, `ff(seconds)` to run the water ahead, `use()`, `select()`) is for tests and tuning from the console. To check a changed map can still be finished, load `core.js` in node, build `new EW.World(map)` and call the tool functions and `step(1/30)` until `isDone()`; every job was checked that way when it was made. **To add a job:** push a map onto `MAPS` in `core.js` after the last one (ids are saved, so never rename or reorder them), give it `needs`, `pay` and `par`, put its Spanish in `es.js`, and finish it with a node script before trying it by hand. +- `e63334287a3deaa3/ebbwork/`: Flood Crew (Back Room; first built as Ebbwork, and the folder, the `ebbwork:v1` save key and the names in the code keep that name), a single-player first-person flood-drainage game: each job is a flooded place, and you work out why it flooded and get it dry (three.js r187 from the site's own build with its r128 layer, then `../autores.js`; no Firebase, no rooms, no stats.js, no ads). It is our own design: the name, the six places, the tools, the prices and the text are ours. **Files:** `index.html` (the page and its styles), `game.js` (shaders, effects, controls, sound, HUD and menus), `models.js` (everything modelled: houses, fences, garden things, the van, drains, pipes, the things you put down, and the first-person hands and tools, all built from simple shapes and pictures drawn on a canvas, as `EWLook`), `core.js` (everything that is not drawing, with no DOM and no three.js in it, so `node` can load it: `require('./core.js')` gives `{EWSim, EW, EWMaps}`), `es.js` (its Spanish for `../lang.js`) and `preview.jpg`. **The water (`EWSim` in `core.js`):** a grid of 0.5 m cells, each with a ground height `g`, a barrier height `bar` laid on top, a depth `d` (kept in 64-bit numbers: with 32-bit ones a slow seep into a deep cell rounded away and volume drifted) and a flow through its right and bottom edge (`fx`, `fy`). Every step (1/30 s, fixed) each edge's flow speeds up by the difference in water surface across it and slows by friction (`fric`, `damp`), no cell may give more than it holds (flows out of a cell are scaled down together), and depths change by what flowed, so volume is conserved exactly: water only appears through `add()` and leaves through `take()`. Walls are `solid` cells. A 3 mm film (`FILM`) never flows, so floors keep real puddles in their dips. Blocks of 8 × 8 cells sleep when nothing in or next to them is changing; an edge into a sleeping block carries nothing and wakes it (leaving that out loses water across the edge). A big pool takes minutes to fall fully asleep because the film keeps creeping, so sleeping saves little while a map is draining; one step with every block awake costs about 1 ms for 128 × 128 cells on a desktop, and the biggest job is 68 × 48. **A job site (`EW.World`):** built from a map's `build(b)` with metres as the unit (x east, z south): `ground`, `shape` and `noise` set heights; `surf` sets the surface type and whether it can be dug; `wall` makes solid blocks (its `kind` is only for drawing); `drain` (a `rate` in m³/s and a `cap`: how much debris blocks it fully), `sinkArea` (water there leaves the map: a ditch or storm channel), `river` (cells held at a level: a stream that both feeds and takes water), `leak` (fed by a `valve` id, or `wrench: true` for a dripping joint), `valve`, `socket`, `litter`, `flood`, `spot` (a note the player gets when they walk near, kept in the journal), `sign`, `station` (the depot's board, bench and van) and `noJob` (cells that don't count). `step(dt)` runs leaks, the river, pumps, drains, sinks, the water and the debris, in that order. Debris floats in more than 5 cm of water, drifts with the current and towards a running drain, strands when the water drops, and blocks a drain by lying within 0.85 m of it (`clog`): a drain's rate is `rate × (0.03 + 0.97 × clear^1.25)`. Debris that has just been raked lies in a sodden heap for 45 seconds (`heavy`) before it can float off again, so a cleared drain stays clear long enough for the level to fall away from the heap. The job is done (`isDone`) when the water left in the job's cells is at most 3% of the most there has been (`World.DONE`) and nothing is still coming in; a skin of water under 8 mm (`World.SKIN`) is wet ground, not flood, and is not counted, which is what stops a job ending in minutes of waiting for a thin sheet to creep away. **Tools (each one a function on the world, so a test can call it):** `rake` (push or pull debris), `scoop` and `pour` (the 30-litre bucket), `squeegee` (moves water under 7 cm one cell along), `dig` and `pile` (soft ground only, down to `DIGMAX` 0.64 m; one stroke takes the cell down 0.24 m and pulls its four neighbours down with it, so a trench is a few strokes and is wide enough to run; piling uses the spoil you dug), `placeBarrier` (three cells in a row, four directions, `BARH` 0.36 m; refused on drains, ditches and the river), `placePump` / `setHose` / `placeGen` (a pump runs when it is on, has a socket or a live generator within cable reach and has a hose end; water it takes goes to the hose end's cell, so emptying into the same pool does nothing, and it only leaves the map if the hose end is on a sink or the river; a generator standing in more than 14 cm of water stops), `takeDebris` (the sack: removes debris for good), `setValve` and `fixLeak`. **The jobs (`EWMaps`, in order; a job opens when the one before has a star):** Marlow Row (a back yard: a drain buried in leaves and a split pipe whose copper supply pipe, drawn along the house wall with `pipe`, leads round the corner to its tap; a new player starts here, standing in it: the yard starts shin to knee deep, half a metre at the drain, so that it plainly is a flood and the before and after are obvious; see **The start** below), Pell Street (three hidden drains, a dripping joint, a paving dip that keeps a puddle), Tanners Field (allotments in a hollow with no drain: a trench through the bank to the ditch; a choked pipe that sits too high to finish the job), Fenny Underpass (a dead sump: pump from a wall socket with the hose over the crest to the storm channel, and a water main valve at the far end), Wharf Cellar (the river seeps in through a doorway: sandbags, then pump up the steps; it is dark, so `sky: 'cellar'` gives a head torch) and Mill Lane (a stream through its bank, a culvert under a raft of debris, a walled garden that needs the pump and the generator, a hollow to trench). `EWMaps.depot` is the depot: not a job, a yard with the job board, the gear bench and the van, and a puddle. **The start (rebuilt 26 Nov 2026 after the owner found the first version confusing):** Play puts a new player straight into Marlow Row holding the rake and nothing else. `TUT` gives one short line at a time at the bottom of the screen (move, find the drain, rake it, follow the pipe to the tap, hold to shut it, keep the drain clear) and each goes when it has been done. What a new player has not met yet is not on screen: `firstJob()` hides the scan and journal buttons, the other tools and the job's notes; the depot appears only after that job, with just the job board working (taking a job from it sets off at once); the gear bench appears after the second job (`shopOpen()`), and the van and its loadout only once the player owns more tools than it holds (`vanNeeded()`). The HUD in a job is a crosshair, one water bar, the tool, and one line of words (`#say`, which carries the instruction or else the latest message); there is no clock or coin count in a job. Each map has `pay`, `par` (the target time in seconds) and `needs` (what the job board suggests bringing, shown only after the player has been there once, so the first visit is for finding out). Stars: one for finishing, a second inside 1.6 × `par`, a third inside `par` with 1.5% or less left; pay is `pay × (0.6 + 0.2 × stars)`, halved when the job has been done before. **Gear** (`GEAR` in the page): tools with `slot: 1` take one of the van's five places (seven with Van racking); the rest are upgrades (more sandbags, long hose, cable reel, second pump, waders, racking). Prices are set so that one-star pay alone affords each next job's tool. **Storage:** localStorage `ebbwork:v1` only: `{v, coins, gear, load, jobs: {: {stars, best, n, seen}}, set: {sens, vol, q, inv}, tut}`; keep `v: 1` and these names working if you change it. Nothing is sent anywhere. **Drawing:** the ground and the water are each one mesh with a vertex at every cell centre. The ground (`terrainMat`) is three's own lit material with our patterns added in `onBeforeCompile` (grain, paving joints, and wet ground that is darker and shiny until it dries over about half a minute, so the band the water has just left is plain to see), which lets it take the sun's shadows and the cellar torch. The water (`waterMat`) is our own shader: its vertices carry depth and speed, a dry cell beside water takes its neighbours' surface height with a negative depth, and the shader throws away everything shallower than 3 mm, so the shoreline is a smooth line where the surface meets the ground and no squares show; it is brown where deep and clear where thin, with a pale lapping line at the edge and a dip pulled into the surface over a working drain. The light is a low warm sun with a cool sky fill; shadows come from one shadow map that is drawn once per site and again only when something is put down (`shadowMap.autoUpdate` is off), 2048 on High and 1024 on Low. Splashes, rings, drops and the pale flecks that ride the current are small pools in `fx` (`ring`, `splash`, `drop`, `fleckSpawn`). Ripples follow the flow, and the scene is drawn once more upside down into a small picture (`renderReflection`) so the water mirrors the buildings and sky: 512 × 320 every frame on High, 256 × 160 every other frame on Low. Low gets it too because without it the water did not read as water on a phone. The walls' materials carry one clipping plane all the time (it only bites during the mirror pass), because switching the renderer's planes on and off each frame made three re-check every material. Graphics: Phones ask for a pixel ratio of up to 2 on any setting, so that `../autores.js`, which can halve it, never takes them under 1. Auto starts High on computers and Low on touch screens and Chromebooks, and steps down to Low for the rest of the visit if frames stay under about 34 a second for nine seconds, after `../autores.js` has had its chance to lower the resolution (`quality`, `autoLow`); it never steps back up by itself. On Low there is one more step for slow phones: if frames stay under about 27 a second for nine seconds, the mirror pass is switched off for the visit (`mirrorOff`) and the water shows the sky only. Walls and props are merged into five meshes by surface (`Batch` in `models.js`: brick, wood, roof, plain and glass), each kind of block a map declares being drawn by `thing()`; debris is three instanced meshes; the first-person hands and tools are each baked into one mesh (`bake`); and things the player puts down are rebuilt together when they change (`EWLook.dyn`). **Sound** is all made in the page with the Web Audio API (`sfx`, `audioTick`): steps and wading, splashes, raking, digging, a gulp when a drain runs shallow, the pump's hum, and a lapping that fades as the place dries. **Touch:** a walk stick on the left (push it right out to run), drag anywhere else to look, and Use and Jump buttons in `#touch`, with Alt (only for tools that have a second use), Do (when you face something to work) and Turn (sandbags) appearing when they apply, all shown only on touch screens; the tool bar moves to the top there. A slow frame is caught up rather than played in slow motion: up to a quarter of a second, as up to eight water steps and the walking split into 40 ms pieces. **Tests:** `window.__ew` (the world, the player, `start(id)`, `ff(seconds)` to run the water ahead, `use()`, `select()`) is for tests and tuning from the console. To check a changed map can still be finished, load `core.js` in node, build `new EW.World(map)` and call the tool functions and `step(1/30)` until `isDone()`; every job was checked that way when it was made. **To add a job:** push a map onto `MAPS` in `core.js` after the last one (ids are saved, so never rename or reorder them), give it `needs`, `pay` and `par`, put its Spanish in `es.js`, and finish it with a node script before trying it by hand. - `e63334287a3deaa3/daily/`: Daily Puzzles (Back Room), the dashboard for every daily puzzle. No libraries, no network except stats.js. `DAILY_GAMES` at the top of the script lists every daily game (`slug` = folder = storage key `daily:`, name, icon, `cat`: word, geo, logic, est (Estimation) or soccer, a one-line blurb, `ready`), plus `EXTRA` link cards under Play together (Puffer Party, `chip` in place of a daily status). Tiles only show for `ready:true` games, and "Coming soon" ones are listed under each category; flip `ready` when a game's folder lands. For each game it reads the shared record `daily:` (written by the game when a daily ends: `{ v:1, days:{YYYYMMDD:{done,win,score,tries,time}}, played, wins, streak, maxStreak, last, dist }`) and shows today's status (Not played, Solved in N / in m:ss, Done, or Missed) and the game's 🔥 streak (only while its last win was today or yesterday). Deepword is read from its own `deepword:` keys. The summary counts today's finished puzzles, the overall streak (days in a row, ending today or yesterday, with at least one daily done, worked out from every game's `days`), and counts down to local midnight; when every ready game is done it shows an "All done today" banner. stats.js (`data-game="daily"`): `max('streak', overall)` and `add('done', 1)` once per game per day (remembered in `daily-hub:counted`). It re-reads storage when the tab comes back into view or another tab writes, so finishing a puzzle in another tab updates it. Test hook: `window.__dh` under webdriver (`setToday`, `render`, `streakOverall`). A game whose win shouldn't read "Solved in " gives a `show` template (`{tries}`, `{score}`, `{time}`; `{score|hint}` adds the word, plural unless the number is 1, and `zero` is the text used when the number is 0): Crosslet shows its time, Ninefold puzzles solved of 3, Crossbar squares, Stat Duel calls right, Top Bins entries found, Quartets mistakes (Perfect for none), Sleight hints, Poopdle moves, Mainstream its points, Yardstick its total out of 500 and Thereabouts its average miss (`{score|x100}`: a score saved as a hundred times a decimal, so 137 reads "1.37×"). A missed puzzle's tile has the finished look but no ✓. Poopdle and Thereabouts are under Logic. `RETIRED`, under `DAILY_GAMES`, holds the daily puzzles taken off the list on 18 Nov 2026 (the least played; see the Back Room page above): they have no tile and aren't in today's total, but their records still count toward the overall streak, so taking a puzzle off never shortens anyone's streak, and a category with nothing listed (Soccer, for now) isn't shown. To bring one back, move its line back into `DAILY_GAMES`. The daily games don't have Back Room or phone-page cards of their own: the Daily Puzzles card and tile are the way in (the phone thumbnails in `m/thumbs/` are kept for if they ever do). - `e63334287a3deaa3/hunch/`: Hunch (Back Room, a daily puzzle on the Daily Puzzles page), a five-letter word guess in six tries, like Wordle. No libraries, no network: `words.js` holds `window.WORDS5 = { ANSWERS, GUESSES }` as space-separated strings, 2,019 answers (common, school-safe, no plurals) and 6,334 more allowed guesses (8,353 in all), written for the site and checked by a script (five letters a–z, no repeats, every answer also a guess, a blocklist for rude words). `ANSWERS` is already in daily order (a fixed seeded shuffle): day n after 1 November 2026 (puzzle #n+1, from the player's local date) uses `ANSWERS[n % length]`, so new answers must be **appended** to keep past days unchanged. Scoring marks greens first, then yellows only for as many copies as the answer has left. Hard mode (Settings, only before a game's first guess) makes every green stay put and every found letter be reused; High contrast swaps green/yellow for orange/blue. Unlimited mode picks random answers and never touches daily stats. Storage: the shared daily record `daily:hunch` (`{ v:1, days:{YYYYMMDD:{done,win,score,tries,time,hard?}}, played, wins, streak, maxStreak, last, dist }`, 60 days kept; the Daily Puzzles page reads it), the day in progress `hunch:day` (`{ d, g:[guesses], hard, t0 }`), Unlimited `hunch:free`, settings `hunch:settings`, `hunch:seen` (how-to shown) and `hunch:mode`. stats.js (`data-game="hunch"`): `add('wins')`, `max('streak')`, `min('fewest')`. The page is generated from the same engine as Fourcast (`CFG` at the top of the script: boards, rows, offset); keep the two in step when fixing the engine. Tile size is worked out in `fit()` (bigger of the layouts that fit); on a sideways phone the keyboard sits right of the board. Test hooks: `window.__wg` under webdriver (`setToday('YYYYMMDD')`, `type(word)`, `score`, …). Thanksgiving Day 2026 (`TG_DAY`) has its own answer, FEAST, set in `answersFor` for Hunch only; every other day and Fourcast are unchanged. **Spanish:** `es.js` has its words (lang.js), with a language switch in Settings; the words are English by design and tagged "En inglés". - `e63334287a3deaa3/fourcast/`: Fourcast (Back Room, a daily puzzle), four five-letter words at once in nine guesses, like Quordle. The same engine as Hunch with `boards: 4, rows: 9, offset: 777`, and the same word lists (it loads `/e63334287a3deaa3/hunch/words.js`, so don't move that file). Each guess goes on every unsolved board; a solved board stops. Day n uses `ANSWERS[(777 + 4n + k) % length]` for boards k = 0–3, so appending answers keeps past days. Each keyboard key shows four corner colours, one per board in reading order (top left = board 1). Tiles may be up to 1.45× wider than tall, and `fit()` picks a 1 × 4 or 2 × 2 layout, whichever gives bigger tiles; on a sideways phone the keyboard stays underneath in short rows. Win = all four within nine; the share card shows the guess each board fell on (🟥 for missed). Storage: `daily:fourcast` (same contract; each day also has `boards`, how many were solved), `fourcast:day`, `fourcast:free`, `fourcast:settings`, `fourcast:seen`, `fourcast:mode`. stats.js: `add('wins')`, `max('streak')`, `min('fewest')`. **Spanish:** `es.js` has its words (lang.js), with a language switch in Settings; the words are English by design and tagged "En inglés". diff --git a/e63334287a3deaa3/ebbwork/core.js b/e63334287a3deaa3/ebbwork/core.js index b9d3736d..08ef07b5 100644 --- a/e63334287a3deaa3/ebbwork/core.js +++ b/e63334287a3deaa3/ebbwork/core.js @@ -15,7 +15,7 @@ var EWSim=(function(){ this.k=new Float32Array(n); this.BW=Math.ceil(W/BS);this.BH=Math.ceil(H/BS);var nb=this.BW*this.BH; this.act=new Uint8Array(nb);this.proc=new Uint8Array(nb);this.was=new Uint8Array(nb); - this.nProc=0;this.fric=0.015;this.damp=0.4; + this.nProc=0;this.fric=0.004;this.damp=0.4; } var P=Sim.prototype; P.idx=function(x,z){return z*this.W+x}; @@ -132,7 +132,7 @@ var EW=(function(){ w.sink=new Uint8Array(n); // 1 = water here leaves the map (ditch, river outfall) w.hold=new Float32Array(n).fill(-1e9); // >-1e8: a river cell held at this surface level w.g0=null;w.boxes=[];w.drains=[];w.leaks=[];w.valves=[];w.debris=[];w.pumps=[];w.barriers=[];w.sockets=[];w.gens=[]; - w.signs=[];w.stations=[];w.spots=[];w.sinkList=[];w.holdList=[];w.dirty=[];w.spoil=0;w.t=0;w.tick=0;w.removed=0;w.added=0;w.holdIn=0;w._hin=0; + w.signs=[];w.stations=[];w.spots=[];w.decos=[];w.pipes=[];w.sinkList=[];w.holdList=[];w.dirty=[];w.spoil=0;w.t=0;w.tick=0;w.removed=0;w.added=0;w.holdIn=0;w._hin=0; w.spawn={x:def.w/2,z:def.h/2,yaw:0};w.rand=mulberry(def.seed||7); w.hoseLen=opt.hoseLen||9;w.cableLen=opt.cableLen||8;w.pumpRate=opt.pumpRate||0.16; def.build(w); @@ -178,6 +178,9 @@ var EW=(function(){ P.station=function(x,z,kind,o){o=o||{};this.stations.push({x:x,z:z,kind:kind,y:o.y==null?1.2:o.y,nx:o.nx||0,nz:o.nz||0})}; // something the player notices when they get near (r metres): shown once and kept in the journal P.spot=function(x,z,r,text){this.spots.push({x:x,z:z,r:r,text:text,seen:false})}; + // drawn only: a garden thing with no collision (kind: 'bush', 'pot'), and a pipe run along a wall + P.deco=function(x,z,kind,o){o=o||{};this.decos.push({x:x,z:z,kind:kind,s:o.s||1,r:o.r||0})}; + P.pipe=function(pts,y){this.pipes.push({pts:pts,y:y==null?0.75:y})}; P.sign=function(x,z,text,o){o=o||{};this.signs.push({x:x,z:z,text:text,y:o.y==null?1.4:o.y,nx:o.nx||0,nz:o.nz||0})}; P.litter=function(x,z,r,n,kind){var w=this;for(var k=0;k1e-5||df<-1e-5){if(df>0)w._hin+=df*AREA;d[i]=want;S.wake(i)}} for(k=0;k=0&&iS.g[dr.i]+0.004)got+=S.take(i,Math.min((q-got),d[i]*AREA*0.5))}} dr.flow+=((got/dt)-dr.flow)*0.2;w.removed+=got} for(k=0;k0){w.removed+=d[i]*AREA;d[i]=0}} @@ -205,7 +208,7 @@ var EW=(function(){ if(w.tick%30===0){w.holdIn=w._hin;w._hin=0} }; P.valveShut=function(id){for(var k=0;k0.002){s+=e;if(e>0.008)c++}} + P.stats=function(){var w=this,d=w.S.d,m=w.mask,n=w.S.n,s=0,c=0,i,e;for(i=0;i0){s+=e;c++}} // a skin of water under 8 mm is wet ground, not flood: it is not counted w.left=s*AREA;w.wet=c;if(w.left>w.peak)w.peak=w.left}; // is any water still coming in? P.incoming=function(){for(var k=0;k0.004}; @@ -218,7 +221,7 @@ var EW=(function(){ P.debrisStep=function(dt){ var w=this,S=w.S,d=S.d,W=w.W,j,k; for(j=0;j0.05;p.fl=fl?1:0; + if(p.heavy>0)p.heavy-=dt;var dd=d[i],fl=dd>0.05&&!(p.heavy>0&&!(p.kick>0));p.fl=fl?1:0; // debris you have just raked lies in a sodden heap for a while before it can float off again if(fl){S.vel(i,vv);var tx=vv[0]*0.8,tz=vv[1]*0.8; for(k=0;k0.01){var ds=Math.sqrt(q),pl=Math.min(0.3,dr.flow*2.5)/(0.6+ds);tx+=dx/ds*pl;tz+=dz/ds*pl} else if(q<=0.01){tx*=0.2;tz*=0.2}} @@ -237,7 +240,7 @@ var EW=(function(){ // rake: push (or pull) debris lying in front of the player P.rake=function(px,pz,dx,dz,pull){var w=this,n=0;for(var j=0;j2.7)continue;var along=(ex*dx+ez*dz);if(q>0.5&&along/q<0.72)continue;if(along<-0.2)continue; - var s=pull?-1:1,side=(ex*-dz+ez*dx);p.vx=s*dx*5.2+(-dz)*side*0.8+(w.rand()-0.5)*0.6;p.vz=s*dz*5.2+dx*side*0.8+(w.rand()-0.5)*0.6;p.kick=0.6;n++} + var s=pull?-1:1,side=(ex*-dz+ez*dx);p.vx=s*dx*5.2+(-dz)*side*0.8+(w.rand()-0.5)*0.6;p.vz=s*dz*5.2+dx*side*0.8+(w.rand()-0.5)*0.6;p.kick=0.6;p.heavy=45;n++} return n}; P.takeDebris=function(x,z,r,max){var w=this,out=[];for(var j=w.debris.length-1;j>=0&&out.length-1e8){this.removed+=vol;return vol}return this.S.add(i,vol)}; P.canDig=function(x,z){var i=this.cell(x,z);return i>=0&&this.soft[i]&&!this.S.solid[i]&&!this.S.bar[i]&&this.S.g[i]>this.g0[i]-World.DIGMAX+0.01}; P.dig=function(x,z){var w=this,S=w.S,i=w.cell(x,z);if(!w.canDig(x,z))return false; - S.g[i]=Math.max(w.g0[i]-World.DIGMAX,S.g[i]-0.16);w.type[i]=T.SOIL;w.spoil++;w.dirty.push(i);S.wake(i); - var nb=[i-1,i+1,i-w.W,i+w.W];for(var m=0;m<4;m++){var j=nb[m];if(j>=0&&jS.g[i]+0.1){S.g[j]-=0.035;w.dirty.push(j);S.wake(j)}} + S.g[i]=Math.max(w.g0[i]-World.DIGMAX,S.g[i]-0.24);w.type[i]=T.SOIL;w.spoil++;w.dirty.push(i);S.wake(i); + var nb=[i-1,i+1,i-w.W,i+w.W];for(var m=0;m<4;m++){var j=nb[m];if(j>=0&&jS.g[i]+0.04){S.g[j]=Math.max(w.g0[j]-World.DIGMAX,Math.max(S.g[i]+0.04,S.g[j]-0.16));w.type[j]=T.SOIL;w.dirty.push(j);S.wake(j)}} return true}; - P.canPile=function(x,z){var i=this.cell(x,z);return i>=0&&this.spoil>0&&this.soft[i]&&!this.S.solid[i]&&!this.S.bar[i]&&this.S.g[i]=0&&this.spoil>0&&this.soft[i]&&!this.S.solid[i]&&!this.S.bar[i]&&this.S.g[i]=0.55;s-=0.5)for(var lat=-0.5;lat<=0.5;lat+=0.5){var cx=px+dx*s-dz*lat,cz=pz+dz*s+dx*lat,c=w.cell(cx,cz),t=w.cell(cx+dx*0.62,cz+dz*0.62); @@ -287,7 +290,7 @@ var EW=(function(){ if(got>0){if(w.sink[p.hose.i]||w.hold[p.hose.i]>-1e8){w.removed+=got;p.away=true}else{S.add(p.hose.i,got);p.away=false}} p.flow+=(got/dt-p.flow)*0.2;p.run=true;p.why=got>q*0.05?'':'dry';return} p.flow*=0.8}; - World.DONE=0.03;World.DIGMAX=0.64;World.BARH=0.36;World.T=T;World.CS=CS;World.vnoise=vnoise; + World.DONE=0.03;World.SKIN=0.008;World.DIGMAX=0.64;World.BARH=0.36;World.T=T;World.CS=CS;World.vnoise=vnoise; return {World:World,T:T,CS:CS}; })(); // The jobs. Sizes are in metres; x runs east, z runs south. Each build() lays out one place. @@ -296,25 +299,26 @@ var EWMaps=(function(){ function dist(x,z,a,b){return Math.sqrt((x-a)*(x-a)+(z-b)*(z-b))} var MAPS=[]; // 1. Marlow Row: a back yard. The patio drain is buried in leaves and the garden tap's pipe has split. - MAPS.push({id:'yard',name:'Marlow Row',sub:'Back yard',w:22,h:18,seed:11,pay:60,par:300,sky:'day', + MAPS.push({id:'yard',name:'Marlow Row',sub:'Back yard',w:22,h:18,seed:11,pay:60,par:210,sky:'day', brief:'The back yard has been under water since the storm, and it is not going down.', build:function(b){ - b.ground(function(x,z){return 0.016*dist(x,z,8,6.5)+Math.max(0,z-9)*0.04}); + b.ground(function(x,z){return 0.02*dist(x,z,8,6.5)+Math.max(0,z-9)*0.04}); b.surf(0,0,22,9,T.PAVE);b.surf(0,9,22,18,T.GRASS,1);b.surf(17,0,22,3,T.GRAVEL); b.noise(0.006,1.7,0,0,22,9);b.noise(0.02,2.3,0,9,22,18); b.wall(0,0,17,3,5.2,0xb9aa94,'house'); b.wall(17,0,22,0.5,1.9,0x8f6f58,'fence');b.wall(21.5,0,22,18,1.9,0x8f6f58,'fence');b.wall(0,17.5,22,18,1.9,0x8f6f58,'fence');b.wall(0,3,0.5,18,1.9,0x8f6f58,'fence'); - b.wall(16.5,12.5,20.5,16,2.3,0x5d7a6a,'shed'); + b.wall(13.5,13,16.5,16,2.2,0x5d7a6a,'shed'); b.wall(1,10,3.5,11,0.5,0x7a5a3c,'planter');b.wall(12.5,3,14,3.5,0.55,0x4c5b66,'bin');b.wall(14.5,3,15.5,3.5,0.9,0x3f6b4c,'bin'); b.wall(5,13.5,6.5,14.5,0.72,0x8a8f93,'table'); - b.drain(8,6.5,{rate:0.13,cap:12}); - b.valve(17.02,1.75,'tap',{nx:1,y:0.8}); - b.leak(4.25,3.25,{rate:0.028,valve:'tap',y:0.75,nz:1,pz:3.02,label:'Garden tap pipe'}); - b.sign(17.02,2.4,'STOP TAP',{nx:1,y:1.35}); - b.litter(8,6.5,0.75,15);b.litter(8,6.5,5,8);b.litter(13,12,5,10);b.litter(4,6,3,4); - b.flood(0,0,22,18,0.235); - b.spot(4.25,4.5,3.5,'The garden tap\'s pipe has split. Its supply pipe runs off along the wall towards the side passage.'); - b.spawnAt(19.3,1.6,Math.PI); + b.drain(8,6.5,{rate:0.62,cap:12}); + b.valve(17.02,1.75,'tap',{nx:1,y:0.95}); + b.leak(4.25,3.25,{rate:0.05,valve:'tap',y:0.95,nz:1,pz:3.02,label:'Garden tap pipe'}); + b.pipe([[5.2,3.04],[16.96,3.04]],0.95);b.pipe([[17.04,3.0],[17.04,1.75]],0.95); + b.wall(18.5,15.2,19,15.7,3.2,0x5b4630,'tree');b.deco(2.2,15.6,'bush',{s:1.2});b.deco(3.6,16.4,'bush',{s:0.9});b.deco(10.5,16.6,'bush',{s:1.1});b.deco(14.2,16.5,'bush',{s:0.8});b.deco(1.4,8.2,'pot');b.deco(16.2,3.5,'pot');b.deco(20.6,6,'bush',{s:0.8}); + b.sign(17.02,2.45,'STOP TAP',{nx:1,y:1.5}); + b.litter(8,6.5,0.8,18);b.litter(8,6.5,5,4);b.litter(13,12,5,10);b.litter(4,6,3,2); + b.flood(0,0,22,18,0.50); // shin to knee deep over the whole patio and half the lawn: it has to look like a flood + b.spawnAt(12.6,11.0,0.80); }}); function bump(u){return u<-1||u>1?0:1-u*u} // 2. Pell Street: shops, a forecourt, and a road whose gullies have vanished under the storm's leftovers. @@ -341,23 +345,23 @@ var EWMaps=(function(){ b.spawnAt(2,9,-Math.PI/2); }}); // 3. Tanners Field: allotments in a hollow. No drain at all: the only way out is over, or through, the bank. - MAPS.push({id:'field',name:'Tanners Field',sub:'Allotments',w:34,h:24,seed:31,pay:160,par:660,sky:'day',needs:['shovel','rake'], + MAPS.push({id:'field',name:'Tanners Field',sub:'Allotments',w:34,h:24,seed:31,pay:160,par:420,sky:'day',needs:['shovel','rake'], brief:'The allotments sit in a hollow. The water came in and has nowhere to go.', build:function(b){ - b.ground(function(x,z){if(x>=30.5)return -0.6;var g=0.30+0.013*dist(x,z,20,12)+0.42*bump((x-28.25)/1.75);if(x>30)g=g+(x-30)*2*(-0.6-g);return g}); + b.ground(function(x,z){if(x>=30.5)return -0.6;var g=0.30+0.015*dist(x,z,22,12)+0.36*bump((x-28.75)/1.25);if(x>30)g=g+(x-30)*2*(-0.6-g);return g}); b.surf(0,0,34,24,T.GRASS,1); for(var k=0;k<4;k++)for(var j=0;j<3;j++)b.surf(3+k*6,5+j*6,7.5+k*6,9.5+j*6,T.SOIL,1); b.surf(30.5,0,34,24,T.GRAVEL,0); - b.noise(0.014,2.2,0,0,30,24); + b.noise(0.005,2.2,0,0,30,24); b.wall(0,0,34,0.5,1.6,0x4b6a3e,'hedge');b.wall(0,23.5,34,24,1.6,0x4b6a3e,'hedge');b.wall(0,0.5,0.5,23.5,1.6,0x4b6a3e,'hedge');b.wall(33.5,0.5,34,23.5,1.6,0x4b6a3e,'hedge'); b.wall(2,1,6,3,2.2,0x6f5b47,'shed');b.wall(8,1,9,2,1.1,0x3e6f8a,'butt');b.wall(12,1,14,2.5,0.9,0x6a563f,'crate');b.wall(1,18,2.5,21,1.0,0x6a563f,'crate'); b.sinkArea(30.5,0.5,33.5,23.5); b.drain(26.25,18.25,{rate:0.05,cap:9,kind:'culvert'}); b.valve(6.02,2,'sp',{nx:1,y:0.8});b.leak(6.75,2.25,{rate:0.03,valve:'sp',y:0.7,nx:1,px:6.02,pz:2.5,label:'Standpipe'}); b.sign(6.02,1.4,'STANDPIPE',{nx:1,y:1.4}); - b.litter(26.25,18.25,0.75,12);b.litter(20,12,8,14); - b.flood(0,0,30,24,0.47); - b.spot(20,12,4,'The lowest point of the field, and there is no drain anywhere on it.');b.spot(28,12,3,'A bank. On the far side the ground drops into a ditch that is nearly empty.');b.spot(26.25,18.25,3,'A small pipe runs under the bank here. It is choked, and it sits too high to empty the middle of the field.'); + b.litter(26.25,18.25,0.75,12);b.litter(22,12,8,14); + b.flood(0,0,30,24,0.43); + b.spot(22,12,4,'The lowest point of the field, and there is no drain anywhere on it.');b.spot(28,12,3,'A bank. On the far side the ground drops into a ditch that is nearly empty.');b.spot(26.25,18.25,3,'A small pipe runs under the bank here. It is choked, and it sits too high to empty the middle of the field.'); b.spawnAt(4,5,Math.PI*0.75+Math.PI); }}); // 4. Fenny Underpass: the road dips under a bridge. The sump pump is dead, so nothing leaves by itself. @@ -402,26 +406,26 @@ var EWMaps=(function(){ b.spawnAt(10.5,1.6,Math.PI); }}); // 6. Mill Lane: the stream has broken its bank and is still coming. - MAPS.push({id:'mill',name:'Mill Lane',sub:'Lane by the stream',w:30,h:24,seed:67,pay:400,par:1050,sky:'day',needs:['sandbags','rake','pump','generator','shovel'], + MAPS.push({id:'mill',name:'Mill Lane',sub:'Lane by the stream',w:30,h:24,seed:67,pay:400,par:540,sky:'day',needs:['sandbags','rake','pump','generator','shovel'], brief:'The mill stream is through its bank and the whole lane is under. Start with whatever is still feeding it.', build:function(b){ b.ground(function(x,z){ if(z<3.5)return 0; - if(z<6){var gap=x>17&&x<20;return gap?0.22:0.30+0.75*bump((z-4.75)/1.25)} + if(z<6){var gap=x>17&&x<20;return gap?0.18:0.30+0.75*bump((z-4.75)/1.25)} var g=0.30-0.0065*x+0.004*Math.abs(z-14); - if(x>1&&x<8&&z>14&&z<22)return -0.15; + if(x>2.5&&x<8&&z>15&&z<21)return 0.0; var hd=dist(x,z,21,20);if(hd<3.5)g-=0.12*bump(hd/3.5);var cd=dist(x,z,28.25,15.25);if(cd<1.6)g-=0.2*bump(cd/1.6); return g}); b.surf(0,0,30,24,T.GRASS,1);b.surf(0,0,30,3.5,T.GRAVEL,0);b.surf(0,9,30,13,T.ROAD,0);b.surf(1,14,8,22,T.PAVE,0);b.surf(18,16.5,26,23.5,T.SOIL,1); - b.noise(0.01,2.1,0,6,30,24); + b.noise(0.004,2.1,0,6,30,24); b.wall(0,0,0.5,24,2.0,0x6e6a62,'wall');b.wall(29.5,0,30,24,2.0,0x6e6a62,'wall');b.wall(0.5,23.5,29.5,24,1.8,0x4b6a3e,'hedge');b.wall(0.5,0,29.5,0.5,1.4,0x4b6a3e,'hedge'); b.wall(0.5,13.5,8.5,14,1.7,0x9a7b63,'fence');b.wall(0.5,22,8.5,22.5,1.7,0x9a7b63,'fence');b.wall(8,14,8.5,17,1.7,0x9a7b63,'fence');b.wall(8,18.5,8.5,22,1.7,0x9a7b63,'fence'); b.wall(10.5,15,16,20,4.6,0xb3a48e,'house');b.wall(22,6.5,26,8.5,2.3,0x5d7a6a,'shed'); - b.river(0.5,0.5,29.5,3.5,0.50); - b.drain(28.25,15.25,{rate:0.4,cap:16,kind:'culvert'});b.drain(14,11,{rate:0.12,cap:10}); + b.river(0.5,0.5,29.5,3.5,0.44); + b.drain(28.25,15.25,{rate:0.7,cap:16,kind:'culvert'});b.drain(14,11,{rate:0.2,cap:10}); b.litter(28.25,15.25,0.8,20);b.litter(14,11,0.7,12);b.litter(15,11,10,18);b.litter(21,20,3,6); b.sign(29.48,15.25,'CULVERT',{nx:-1,y:1.3}); - b.flood(0.5,3.5,29.5,23.5,0.46); + b.flood(0.5,3.5,29.5,23.5,0.40); b.spot(18.5,7.5,3.5,'The stream is pouring through a gap in its bank. Nothing will dry out while it does.');b.spot(4.5,18,3.5,'A sunken garden with a wall round it. There is no drain in it and no power anywhere near.');b.spot(21,20,3,'A hollow in the vegetable patch. The ground between here and the culvert is soft.');b.spot(26.5,15.25,3,'The culvert under the lane. Everything on this side of the bank should be leaving through it.'); b.spawnAt(3,9.5,-Math.PI/2); }}); diff --git a/e63334287a3deaa3/ebbwork/es.js b/e63334287a3deaa3/ebbwork/es.js index edba58a4..78507017 100644 --- a/e63334287a3deaa3/ebbwork/es.js +++ b/e63334287a3deaa3/ebbwork/es.js @@ -1,83 +1,164 @@ /* Flood Crew (first built as Ebbwork; the folder and save key keep that name) in Spanish: this game's own words - for lang.js (see the comment at the top of ../lang.js). The game's name and the place names (Marlow Row, Pell Street...) stay in English as names; the signs painted - on walls inside the jobs stay in English too. Everything else is translated. */ + for lang.js (see the comment at the top of ../lang.js). The game's name and the place names (Marlow Row, Pell Street...) + stay in English as names; the signs painted on walls inside the jobs stay in English too. Everything else is translated. */ if (window.BackRoomLang) BackRoomLang.add({ - // title, menus - 'The storm has gone but the water has not. Find out why each place flooded, then get it dry.': 'La tormenta ya pasó, pero el agua no. Descubre por qué se inundó cada lugar y déjalo seco.', - 'Go to the depot': 'Ir al depósito', 'How to play': 'Cómo jugar', 'Settings': 'Ajustes', 'Your progress saves by itself in this browser.': 'Tu progreso se guarda solo en este navegador.', - 'Job board': 'Tablero de trabajos', 'Close': 'Cerrar', 'Take this job': 'Tomar este trabajo', 'Gear': 'Equipo', 'Done': 'Listo', 'Load the van': 'Cargar la camioneta', 'Not yet': 'Todavía no', 'Drive to the job': 'Ir al trabajo', - 'Paused': 'En pausa', 'Back to work': 'Volver al trabajo', 'Journal': 'Diario', 'Start this job again': 'Empezar este trabajo de nuevo', 'Leave the job': 'Dejar el trabajo', 'Back to the title': 'Volver al inicio', - 'Look speed': 'Velocidad de la vista', 'Sound': 'Sonido', 'Graphics': 'Gráficos', 'Low': 'Bajos', 'Auto': 'Auto', 'High': 'Altos', 'Look up/down': 'Mirar arriba/abajo', 'Normal': 'Normal', 'Flipped': 'Invertido', 'Full screen': 'Pantalla completa', - 'Every job is a flooded place. Something is keeping it wet: a blocked drain, a leak, ground with nowhere to run to. Work out what, fix it, and get the water under the green mark on the gauge.': 'Cada trabajo es un lugar inundado. Algo lo mantiene mojado: un desagüe tapado, una fuga, un terreno sin salida. Descubre qué es, arréglalo y baja el agua hasta la marca verde del medidor.', - 'Walk': 'Caminar', 'Mouse': 'Mouse', 'Look': 'Mirar', 'Jump, run, duck': 'Saltar, correr, agacharse', 'Left click': 'Clic izquierdo', 'Use the tool in your hands': 'Usar la herramienta que llevas', 'Right click': 'Clic derecho', "The tool's other use": 'El otro uso de la herramienta', - 'Hold to work a valve or other fitting': 'Mantén para accionar una llave u otra pieza', '/ wheel': '/ rueda', 'Change tool': 'Cambiar de herramienta', 'Turn something before you put it down': 'Girar algo antes de colocarlo', 'Scan: shows the water that is left': 'Escanear: muestra el agua que queda', 'Pause': 'Pausa', - 'Left thumb': 'Pulgar izquierdo', 'Walk (push all the way to run)': 'Caminar (empuja hasta el fondo para correr)', 'Drag': 'Arrastrar', 'Use / Alt': 'Usar / Alt', 'The tool in your hands, and its other use': 'La herramienta que llevas y su otro uso', 'Tool bar': 'Barra de herramientas', 'Tap a tool to hold it': 'Toca una herramienta para tomarla', 'Got it': 'Entendido', - 'Job done': 'Trabajo terminado', 'Do it again': 'Hacerlo de nuevo', 'Back to the depot': 'Volver al depósito', 'Flood Crew game view': 'Vista del juego Flood Crew', 'Scan for water': 'Buscar agua', - // HUD and touch buttons - 'Water left': 'Agua restante', 'Water is still coming in': 'Sigue entrando agua', 'Use': 'Usar', 'Alt': 'Alt', 'Jump': 'Saltar', 'Duck': 'Agachar', 'Turn': 'Girar', 'Do': 'Hacer', - 'Hold Do': 'Mantén Hacer', 'Hold E': 'Mantén E', 'Hold Use': 'Mantén Usar', 'Hold click': 'Mantén el clic', - 'open the stop tap': 'abrir la llave de paso', 'shut the stop tap': 'cerrar la llave de paso', 'tighten the joint': 'apretar la unión', 'A dripping joint. It needs the wrench.': 'Una unión que gotea. Hace falta la llave inglesa.', - 'switch off': 'apagar', 'switch on': 'encender', 'look at the job board': 'mirar el tablero de trabajos', 'buy gear': 'comprar equipo', 'load the van': 'cargar la camioneta', - 'Stop tap shut.': 'Llave de paso cerrada.', 'Stop tap open.': 'Llave de paso abierta.', 'Joint tightened.': 'Unión apretada.', - 'JOB BOARD': 'TRABAJOS', 'GEAR': 'EQUIPO', 'LOAD THE VAN': 'CARGAR', - // pump and tool messages - 'Switched off.': 'Apagada.', 'No power. It needs a socket or a generator within {n} m.': 'Sin corriente. Necesita un enchufe o un generador a menos de {n} m.', 'Its generator is under water.': 'Su generador está bajo el agua.', 'No hose laid yet.': 'Todavía no tiene manguera tendida.', - 'Running, but there is nothing here to pump.': 'Funciona, pero aquí no hay nada que bombear.', 'Pumping {n} litres a second away.': 'Sacando {n} litros por segundo.', 'Pumping, but the water is running straight back.': 'Bombea, pero el agua vuelve enseguida.', - 'No water to scoop here.': 'Aquí no hay agua que recoger.', 'You cannot pile soil there.': 'Ahí no puedes amontonar tierra.', 'No spoil to put back yet. Dig first.': 'Todavía no hay tierra que devolver. Cava primero.', 'Too hard to dig. Try soil or grass.': 'Demasiado duro para cavar. Prueba en tierra o pasto.', 'That is as deep as this trench will go.': 'Esta zanja no puede ser más honda.', - 'The sack is full.': 'El saco está lleno.', 'No sandbags left. Pick a row up to move it.': 'No quedan sacos de arena. Levanta una fila para moverla.', 'The bags will not sit there.': 'Los sacos no se sostienen ahí.', 'Hose laid.': 'Manguera tendida.', 'The hose will not reach that far ({n} m).': 'La manguera no llega tan lejos ({n} m).', - 'Point where the hose should empty, and use the pump again.': 'Apunta adonde debe vaciar la manguera y usa la bomba otra vez.', 'The pump is already out. Pick it up to move it.': 'La bomba ya está colocada. Levántala para moverla.', + 'How to play': 'Cómo jugar', + 'Settings': 'Ajustes', + 'Close': 'Cerrar', + 'Take this job': 'Tomar este trabajo', + 'Gear': 'Equipo', + 'Done': 'Listo', + 'Load the van': 'Cargar la camioneta', + 'Not yet': 'Todavía no', + 'Drive to the job': 'Ir al trabajo', + 'Paused': 'En pausa', + 'Back to work': 'Volver al trabajo', + 'Journal': 'Diario', + 'Start this job again': 'Empezar este trabajo de nuevo', + 'Leave the job': 'Dejar el trabajo', + 'Back to the title': 'Volver al inicio', + 'Look speed': 'Velocidad de la vista', + 'Sound': 'Sonido', + 'Graphics': 'Gráficos', + 'Low': 'Bajos', + 'Auto': 'Auto', + 'High': 'Altos', + 'Look up/down': 'Mirar arriba/abajo', + 'Normal': 'Normal', + 'Flipped': 'Invertido', + 'Full screen': 'Pantalla completa', + 'Walk': 'Caminar', + 'Mouse': 'Mouse', + 'Look': 'Mirar', + 'Left click': 'Clic izquierdo', + 'Right click': 'Clic derecho', + 'Change tool': 'Cambiar de herramienta', + 'Pause': 'Pausa', + 'Left thumb': 'Pulgar izquierdo', + 'Walk (push all the way to run)': 'Caminar (empuja hasta el fondo para correr)', + 'Drag': 'Arrastrar', + 'Got it': 'Entendido', + 'Flood Crew game view': 'Vista del juego Flood Crew', + 'Scan for water': 'Buscar agua', + 'Water left': 'Agua restante', + 'Use': 'Usar', + 'Alt': 'Alt', + 'Jump': 'Saltar', + 'Turn': 'Girar', + 'Do': 'Hacer', + 'Hold Do': 'Mantén Hacer', + 'Hold E': 'Mantén E', + 'Hold Use': 'Mantén Usar', + 'Hold click': 'Mantén el clic', + 'tighten the joint': 'apretar la unión', + 'A dripping joint. It needs the wrench.': 'Una unión que gotea. Hace falta la llave inglesa.', + 'switch off': 'apagar', + 'switch on': 'encender', + 'buy gear': 'comprar equipo', + 'load the van': 'cargar la camioneta', + 'Joint tightened.': 'Unión apretada.', + 'GEAR': 'EQUIPO', + 'Switched off.': 'Apagada.', + 'No power. It needs a socket or a generator within {n} m.': 'Sin corriente. Necesita un enchufe o un generador a menos de {n} m.', + 'Its generator is under water.': 'Su generador está bajo el agua.', + 'No hose laid yet.': 'Todavía no tiene manguera tendida.', + 'Running, but there is nothing here to pump.': 'Funciona, pero aquí no hay nada que bombear.', + 'Pumping {n} litres a second away.': 'Sacando {n} litros por segundo.', + 'Pumping, but the water is running straight back.': 'Bombea, pero el agua vuelve enseguida.', + 'No water to scoop here.': 'Aquí no hay agua que recoger.', + 'You cannot pile soil there.': 'Ahí no puedes amontonar tierra.', + 'Too hard to dig. Try soil or grass.': 'Demasiado duro para cavar. Prueba en tierra o pasto.', + 'That is as deep as this trench will go.': 'Esta zanja no puede ser más honda.', + 'The sack is full.': 'El saco está lleno.', + 'No sandbags left. Pick a row up to move it.': 'No quedan sacos de arena. Levanta una fila para moverla.', + 'The bags will not sit there.': 'Los sacos no se sostienen ahí.', + 'Hose laid.': 'Manguera tendida.', + 'The hose will not reach that far ({n} m).': 'La manguera no llega tan lejos ({n} m).', + 'Point where the hose should empty, and use the pump again.': 'Apunta adonde debe vaciar la manguera y usa la bomba otra vez.', + 'The pump is already out. Pick it up to move it.': 'La bomba ya está colocada. Levántala para moverla.', 'Pump down and plugged in. Now point where the hose should empty, and use the pump again.': 'Bomba colocada y enchufada. Ahora apunta adonde debe vaciar la manguera y usa la bomba otra vez.', 'Pump down, but there is no power within {n} m. Now point where the hose should empty, and use the pump again.': 'Bomba colocada, pero no hay corriente a menos de {n} m. Ahora apunta adonde debe vaciar la manguera y usa la bomba otra vez.', - 'The generator is already out. Pick it up to move it.': 'El generador ya está colocado. Levántalo para moverlo.', 'Too wet. It would drown here.': 'Demasiada agua. Aquí se ahogaría.', - '{v} litres still lying here, over {n} square metres.': 'Quedan {v} litros aquí, en {n} metros cuadrados.', 'No standing water found.': 'No se encontró agua estancada.', - // journal - 'Find where this water should be draining to': 'Encuentra por dónde debería irse esta agua', 'Low points are a good place to look.': 'Los puntos bajos son un buen lugar para buscar.', 'Keep the culvert clear': 'Mantén despejada la alcantarilla', 'Keep the drain clear': 'Mantén despejado el desagüe', 'Running freely.': 'Corre sin problemas.', - '{p}% blocked. Rake the debris well away, or it will wash back.': 'Tapado al {p}%. Aleja bien los restos con el rastrillo o el agua los traerá de vuelta.', 'Find out if water is still getting in': 'Averigua si sigue entrando agua', 'Listen, and look along the walls.': 'Escucha y mira a lo largo de las paredes.', 'Stop the leak': 'Detén la fuga', - 'The pipe is under pressure. Follow it back to a stop tap.': 'El caño tiene presión. Síguelo hasta una llave de paso.', 'A dripping joint. Tighten it with the wrench.': 'Una unión que gotea. Apriétala con la llave inglesa.', 'Stopped.': 'Detenida.', - 'Stop the water getting in from outside': 'Impide que entre agua de afuera', 'Held back.': 'Contenida.', 'Something has to stand in its way.': 'Algo tiene que cerrarle el paso.', 'Pump': 'Bomba', 'Get the water under the green mark': 'Baja el agua hasta la marca verde', '{p}% left. Small puddles are fine.': 'Queda el {p}%. Los charcos chicos no importan.', - 'What you have noticed': 'Lo que has notado', 'The job board has the work, the bench sells gear, and the van takes you there.': 'El tablero tiene los trabajos, en el banco se compra equipo y la camioneta te lleva.', - 'A drain, buried in debris. That is one reason the water is staying.': 'Un desagüe, enterrado bajo restos. Es una de las razones por las que el agua no se va.', 'A drain.': 'Un desagüe.', 'A joint is dripping steadily here.': 'Aquí gotea una unión sin parar.', - 'Water is pouring out of a split pipe here. Nothing will drain for long while this runs.': 'Aquí sale agua a chorros de un caño rajado. Nada va a secarse mientras siga así.', - // depot, results - 'Job taken: {j}. Load the van when you are ready.': 'Trabajo tomado: {j}. Carga la camioneta cuando quieras.', 'Your depot. The job board is on the wall ahead.': 'Tu depósito. El tablero de trabajos está en la pared de enfrente.', - 'Time': 'Tiempo', 'target': 'meta', 'Pay (half: you have done this job before)': 'Paga (la mitad: ya hiciste este trabajo)', 'Pay': 'Paga', 'Your coins': 'Tus monedas', 'Finish {j} first': 'Termina {j} primero', 'not owned': 'no lo tienes', - 'Pays up to': 'Paga hasta', 'Target time': 'Tiempo meta', 'Your best': 'Tu mejor tiempo', 'From your last visit, worth bringing:': 'De tu última visita, conviene llevar:', 'Nobody has looked at it yet. Go and see what it needs; you can always come back for more gear.': 'Nadie lo ha revisado todavía. Ve a ver qué necesita; siempre puedes volver por más equipo.', - 'Done before: a repeat pays half.': 'Ya lo hiciste: repetirlo paga la mitad.', 'Needs: {g}.': 'Requiere: {g}.', 'Owned': 'Ya lo tienes', 'Going to: {j}. Room for {n} kinds of tool.': 'Destino: {j}. Hay lugar para {n} tipos de herramienta.', 'No job taken yet. Pick one from the job board first.': 'Todavía no tomaste ningún trabajo. Elige uno en el tablero primero.', - 'On the van': 'En la camioneta', 'The van is full. Take something off first.': 'La camioneta está llena. Baja algo primero.', - // gear - 'Rake': 'Rastrillo', 'Bucket': 'Balde', 'Wrench': 'Llave inglesa', 'Squeegee': 'Secador', 'Shovel': 'Pala', 'Debris sack': 'Saco para restos', 'Sandbags': 'Sacos de arena', 'Generator': 'Generador', 'More sandbags': 'Más sacos de arena', 'Long hose': 'Manguera larga', 'Cable reel': 'Carrete de cable', 'Second pump': 'Segunda bomba', 'Waders': 'Botas altas', 'Van racking': 'Estantes para la camioneta', - 'Pushes and pulls leaves and litter off a drain.': 'Empuja y arrastra hojas y basura para destapar un desagüe.', 'Carries 30 litres at a time, for the puddles nothing else can reach.': 'Lleva 30 litros por vez, para los charcos a los que nada más llega.', 'Tightens dripping joints.': 'Aprieta las uniones que gotean.', - 'Shoves thin water across a hard floor, towards a drain or a doorway.': 'Empuja el agua poco profunda por un piso duro, hacia un desagüe o una puerta.', 'Cuts a trench in soft ground so water can run downhill. It can pile the spoil back up, too.': 'Abre una zanja en terreno blando para que el agua corra cuesta abajo. También puede volver a amontonar la tierra.', - 'Bags up to 40 bits of debris for good, so they cannot wash back.': 'Guarda hasta 40 restos para siempre, así el agua no los trae de vuelta.', 'Four rows of bags. Lay them across a gap to hold water back.': 'Cuatro filas de sacos. Ponlas atravesando un hueco para contener el agua.', + 'The generator is already out. Pick it up to move it.': 'El generador ya está colocado. Levántalo para moverlo.', + 'Too wet. It would drown here.': 'Demasiada agua. Aquí se ahogaría.', + 'No standing water found.': 'No se encontró agua estancada.', + 'Find where this water should be draining to': 'Encuentra por dónde debería irse esta agua', + 'Low points are a good place to look.': 'Los puntos bajos son un buen lugar para buscar.', + 'Keep the culvert clear': 'Mantén despejada la alcantarilla', + 'Keep the drain clear': 'Mantén despejado el desagüe', + 'Running freely.': 'Corre sin problemas.', + '{p}% blocked. Rake the debris well away, or it will wash back.': 'Tapado al {p}%. Aleja bien los restos con el rastrillo o el agua los traerá de vuelta.', + 'Find out if water is still getting in': 'Averigua si sigue entrando agua', + 'Listen, and look along the walls.': 'Escucha y mira a lo largo de las paredes.', + 'Stop the leak': 'Detén la fuga', + 'A dripping joint. Tighten it with the wrench.': 'Una unión que gotea. Apriétala con la llave inglesa.', + 'Stopped.': 'Detenida.', + 'Stop the water getting in from outside': 'Impide que entre agua de afuera', + 'Held back.': 'Contenida.', + 'Something has to stand in its way.': 'Algo tiene que cerrarle el paso.', + 'Pump': 'Bomba', + '{p}% left. Small puddles are fine.': 'Queda el {p}%. Los charcos chicos no importan.', + 'What you have noticed': 'Lo que has notado', + 'A drain.': 'Un desagüe.', + 'A joint is dripping steadily here.': 'Aquí gotea una unión sin parar.', + 'Time': 'Tiempo', + 'target': 'meta', + 'Pay': 'Paga', + 'not owned': 'no lo tienes', + 'Pays up to': 'Paga hasta', + 'Done before: a repeat pays half.': 'Ya lo hiciste: repetirlo paga la mitad.', + 'Needs: {g}.': 'Requiere: {g}.', + 'Owned': 'Ya lo tienes', + 'Going to: {j}. Room for {n} kinds of tool.': 'Destino: {j}. Hay lugar para {n} tipos de herramienta.', + 'No job taken yet. Pick one from the job board first.': 'Todavía no tomaste ningún trabajo. Elige uno en el tablero primero.', + 'On the van': 'En la camioneta', + 'The van is full. Take something off first.': 'La camioneta está llena. Baja algo primero.', + 'Rake': 'Rastrillo', + 'Bucket': 'Balde', + 'Wrench': 'Llave inglesa', + 'Squeegee': 'Secador', + 'Shovel': 'Pala', + 'Debris sack': 'Saco para restos', + 'Sandbags': 'Sacos de arena', + 'Generator': 'Generador', + 'More sandbags': 'Más sacos de arena', + 'Long hose': 'Manguera larga', + 'Cable reel': 'Carrete de cable', + 'Second pump': 'Segunda bomba', + 'Waders': 'Botas altas', + 'Van racking': 'Estantes para la camioneta', + 'Pushes and pulls leaves and litter off a drain.': 'Empuja y arrastra hojas y basura para destapar un desagüe.', + 'Carries 30 litres at a time, for the puddles nothing else can reach.': 'Lleva 30 litros por vez, para los charcos a los que nada más llega.', + 'Tightens dripping joints.': 'Aprieta las uniones que gotean.', + 'Shoves thin water across a hard floor, towards a drain or a doorway.': 'Empuja el agua poco profunda por un piso duro, hacia un desagüe o una puerta.', + 'Cuts a trench in soft ground so water can run downhill. It can pile the spoil back up, too.': 'Abre una zanja en terreno blando para que el agua corra cuesta abajo. También puede volver a amontonar la tierra.', + 'Bags up to 40 bits of debris for good, so they cannot wash back.': 'Guarda hasta 40 restos para siempre, así el agua no los trae de vuelta.', + 'Four rows of bags. Lay them across a gap to hold water back.': 'Cuatro filas de sacos. Ponlas atravesando un hueco para contener el agua.', 'Lifts water out of places with no way down. It needs power within 8 m, and a hose end somewhere the water can get away.': 'Saca el agua de lugares sin salida hacia abajo. Necesita corriente a menos de 8 m y la punta de la manguera donde el agua pueda irse.', - 'Power for the pump where there is no socket. Keep it out of the water.': 'Corriente para la bomba donde no hay enchufe. Mantenlo fuera del agua.', 'Four more rows on the van.': 'Cuatro filas más en la camioneta.', '16 m of hose in place of 9.': '16 m de manguera en lugar de 9.', '18 m of cable in place of 8.': '18 m de cable en lugar de 8.', - 'Two pumps on the van.': 'Dos bombas en la camioneta.', 'Deep water slows you far less.': 'El agua profunda te frena mucho menos.', 'Room for seven kinds of tool in place of five.': 'Lugar para siete tipos de herramienta en lugar de cinco.', - // tool tips - 'Click: push debris away · Right click: pull it to you': 'Clic: empujar los restos · Clic derecho: traerlos hacia ti', 'Use: push debris · Alt: pull it': 'Usar: empujar restos · Alt: traerlos', 'Click: fill from water, or tip out · Right click: tip out': 'Clic: llenar con agua o vaciar · Clic derecho: vaciar', 'Use: fill, or tip out': 'Usar: llenar o vaciar', - 'Hold click on a dripping joint to tighten it': 'Mantén el clic sobre una unión que gotea para apretarla', 'Hold Use on a dripping joint': 'Mantén Usar sobre una unión que gotea', 'Click: push thin water the way you face': 'Clic: empujar el agua poco profunda hacia donde miras', 'Use: push thin water forward': 'Usar: empujar el agua poco profunda', - 'Click: dig soft ground · Right click: put spoil back': 'Clic: cavar terreno blando · Clic derecho: devolver la tierra', 'Use: dig · Alt: put spoil back': 'Usar: cavar · Alt: devolver la tierra', 'Click: bag the debris in front of you for good': 'Clic: guardar para siempre los restos que tienes delante', 'Use: bag debris for good': 'Usar: guardar restos para siempre', - 'Click: lay a row · R: turn it · Right click: pick a row up': 'Clic: poner una fila · R: girarla · Clic derecho: levantar una fila', 'Use: lay a row · Turn · Alt: pick up': 'Usar: poner una fila · Girar · Alt: levantar', - 'Click: put the pump down, then click where the hose should empty · Right click: pick it up': 'Clic: colocar la bomba y luego clic donde debe vaciar la manguera · Clic derecho: levantarla', 'Use: place, then point the hose · Alt: pick up': 'Usar: colocar y luego apuntar la manguera · Alt: levantar', - 'Click: put it down on dry ground · Right click: pick it up': 'Clic: colocarlo en suelo seco · Clic derecho: levantarlo', 'Use: put down · Alt: pick up': 'Usar: colocar · Alt: levantar', - // first job walkthrough - 'Walk into the yard and look for where the water ought to be going.': 'Entra al patio y busca por dónde debería irse el agua.', - 'That is the drain, under the debris. Hold the rake (1) and click to push the debris off it. Push it a long way.': 'Ese es el desagüe, bajo los restos. Toma el rastrillo (1) y haz clic para quitarle los restos de encima. Empújalos bien lejos.', - 'That is the drain, under the debris. With the rake, tap Use to push the debris off it. Push it a long way.': 'Ese es el desagüe, bajo los restos. Con el rastrillo, toca Usar para quitarle los restos de encima. Empújalos bien lejos.', - 'Better, but the gauge says water is still coming in. Find what is feeding it.': 'Mejor, pero el medidor dice que sigue entrando agua. Encuentra de dónde viene.', - 'A split pipe. It cannot be mended under pressure: follow the pipe along the wall to its stop tap, and hold E on it.': 'Un caño rajado. No se puede arreglar con presión: sigue el caño por la pared hasta su llave de paso y mantén E sobre ella.', - 'A split pipe. It cannot be mended under pressure: follow the pipe along the wall to its stop tap, and hold Do on it.': 'Un caño rajado. No se puede arreglar con presión: sigue el caño por la pared hasta su llave de paso y mantén Hacer sobre ella.', - 'Now keep the drain clear while it empties. Debris floats back. F shows the water that is left.': 'Ahora mantén despejado el desagüe mientras se vacía. Los restos vuelven flotando. Con F ves el agua que queda.', - 'Now keep the drain clear while it empties. Debris floats back. The scan button shows the water that is left.': 'Ahora mantén despejado el desagüe mientras se vacía. Los restos vuelven flotando. El botón de escanear muestra el agua que queda.', - 'Nearly there. The green mark on the gauge is all you need: small puddles do not matter.': 'Ya casi. Solo necesitas llegar a la marca verde del medidor: los charcos chicos no importan.', - // the jobs - 'Back yard': 'Patio trasero', 'Shop fronts': 'Frente de los locales', 'Allotments': 'Huertas', 'Road under the bridge': 'Calle bajo el puente', 'Warehouse cellar': 'Sótano del almacén', 'Lane by the stream': 'Camino junto al arroyo', 'Your yard': 'Tu patio', + 'Power for the pump where there is no socket. Keep it out of the water.': 'Corriente para la bomba donde no hay enchufe. Mantenlo fuera del agua.', + 'Four more rows on the van.': 'Cuatro filas más en la camioneta.', + '16 m of hose in place of 9.': '16 m de manguera en lugar de 9.', + '18 m of cable in place of 8.': '18 m de cable en lugar de 8.', + 'Two pumps on the van.': 'Dos bombas en la camioneta.', + 'Deep water slows you far less.': 'El agua profunda te frena mucho menos.', + 'Room for seven kinds of tool in place of five.': 'Lugar para siete tipos de herramienta en lugar de cinco.', + 'Use: fill, or tip out': 'Usar: llenar o vaciar', + 'Hold Use on a dripping joint': 'Mantén Usar sobre una unión que gotea', + 'Use: push thin water forward': 'Usar: empujar el agua poco profunda', + 'Use: place, then point the hose · Alt: pick up': 'Usar: colocar y luego apuntar la manguera · Alt: levantar', + 'Use: put down · Alt: pick up': 'Usar: colocar · Alt: levantar', + 'Back yard': 'Patio trasero', + 'Shop fronts': 'Frente de los locales', + 'Allotments': 'Huertas', + 'Road under the bridge': 'Calle bajo el puente', + 'Warehouse cellar': 'Sótano del almacén', + 'Lane by the stream': 'Camino junto al arroyo', + 'Your yard': 'Tu patio', 'The back yard has been under water since the storm, and it is not going down.': 'El patio trasero está bajo el agua desde la tormenta, y no baja.', 'The road outside the shops is a pond and the loading bay has filled to the brim.': 'La calle frente a los locales es un estanque y la zona de carga se llenó hasta el borde.', 'The allotments sit in a hollow. The water came in and has nowhere to go.': 'Las huertas están en una hondonada. El agua entró y no tiene adónde ir.', 'The road under the bridge is shut. The council says its pump has given up.': 'La calle bajo el puente está cerrada. El municipio dice que su bomba dejó de funcionar.', 'The cellar under the old wharf keeps filling. The owner has bailed it twice already.': 'El sótano bajo el viejo muelle se sigue llenando. El dueño ya lo vació dos veces.', 'The mill stream is through its bank and the whole lane is under. Start with whatever is still feeding it.': 'El arroyo del molino rompió su orilla y todo el camino está bajo el agua. Empieza por lo que lo sigue alimentando.', - "The garden tap's pipe has split. Its supply pipe runs off along the wall towards the side passage.": 'El caño de la canilla del jardín se rajó. Su caño de entrada sigue por la pared hacia el pasillo del costado.', 'The loading bay is lower than everything around it. It has a small drain of its own somewhere under that water.': 'La zona de carga está más baja que todo lo que la rodea. Tiene un desagüe chico propio en algún lugar bajo esa agua.', 'A dip in the paving. It will hold a puddle whatever the drains do.': 'Un hundimiento en las baldosas. Va a guardar un charco hagan lo que hagan los desagües.', 'A road like this has gullies along the kerb. None are showing.': 'Una calle así tiene bocas de tormenta junto al cordón. No se ve ninguna.', @@ -93,5 +174,59 @@ if (window.BackRoomLang) BackRoomLang.add({ 'The stream is pouring through a gap in its bank. Nothing will dry out while it does.': 'El arroyo entra a chorros por un hueco en su orilla. Nada se va a secar mientras siga así.', 'A sunken garden with a wall round it. There is no drain in it and no power anywhere near.': 'Un jardín hundido rodeado por un muro. No tiene desagüe ni hay corriente cerca.', 'A hollow in the vegetable patch. The ground between here and the culvert is soft.': 'Una hondonada en la huerta. El terreno entre aquí y la alcantarilla es blando.', - 'The culvert under the lane. Everything on this side of the bank should be leaving through it.': 'La alcantarilla bajo el camino. Todo lo que hay de este lado de la orilla debería irse por ella.' + 'The culvert under the lane. Everything on this side of the bank should be leaving through it.': 'La alcantarilla bajo el camino. Todo lo que hay de este lado de la orilla debería irse por ella.', + 'No soil to put back yet. Dig first.': 'Todavía no hay tierra que devolver. Cava primero.', + '{v} litres still lying here.': 'Quedan {v} litros aquí.', + 'Follow its pipe back to a tap.': 'Sigue su caño hasta una llave.', + 'Get the water down to the green mark': 'Baja el agua hasta la marca verde', + 'A drain, buried in debris.': 'Un desagüe, enterrado bajo restos.', + 'Water is pouring out of a split pipe here.': 'Aquí sale agua a chorros de un caño rajado.', + 'open the tap': 'abrir la llave', + 'shut the tap': 'cerrar la llave', + 'pick a job': 'elegir un trabajo', + 'Tap shut.': 'Llave cerrada.', + 'Tap open.': 'Llave abierta.', + 'You have pay to spend. The gear bench is on the right': 'Tienes paga para gastar. El banco de equipo está a la derecha', + 'Pick your next job from the board': 'Elige tu próximo trabajo en el tablero', + '{p} is dry': '{p} está seco', + 'Pay (half for a repeat)': 'Paga (la mitad por repetir)', + 'Locked': 'Bloqueado', + 'Worth bringing:': 'Conviene llevar:', + 'Pays up to {n}': 'Paga hasta {n}', + 'Go': 'Ir', + 'Job taken. Load the van to set off.': 'Trabajo tomado. Carga la camioneta para salir.', + 'Click to rake': 'Clic para rastrillar', + 'Use: rake': 'Usar: rastrillar', + 'Click: fill it, or tip it out': 'Clic: llenarlo o vaciarlo', + 'Hold click on a dripping joint': 'Mantén el clic sobre una unión que gotea', + 'Click: push thin water forward': 'Clic: empujar el agua poco profunda', + 'Click: dig · Right click: put soil back': 'Clic: cavar · Clic derecho: devolver la tierra', + 'Use: dig · Alt: put soil back': 'Usar: cavar · Alt: devolver la tierra', + 'Click: bag the debris in front of you': 'Clic: guardar los restos que tienes delante', + 'Use: bag debris': 'Usar: guardar restos', + 'Click: lay a row · R: turn · Right click: pick up': 'Clic: poner una fila · R: girar · Clic derecho: levantar', + 'Use: lay a row · Alt: pick up': 'Usar: poner una fila · Alt: levantar', + 'Click: put it down, then click where the hose empties · Right click: pick up': 'Clic: colocarla y luego clic donde vacía la manguera · Clic derecho: levantar', + 'Click: put it down somewhere dry · Right click: pick up': 'Clic: colocarlo en un lugar seco · Clic derecho: levantar', + 'Move with W A S D. Look with the mouse.': 'Muévete con W A S D. Mira con el mouse.', + 'Find the drain under the leaves': 'Encuentra el desagüe bajo las hojas', + 'Click to rake the leaves off the drain': 'Haz clic para quitar las hojas del desagüe', + 'Water is still pouring in. Follow the copper pipe to its tap': 'Sigue entrando agua. Sigue el caño de cobre hasta su llave', + 'Hold E to shut the tap': 'Mantén E para cerrar la llave', + 'Keep the drain clear until the yard is dry': 'Mantén despejado el desagüe hasta que el patio esté seco', + 'Left thumb walks. Drag to look.': 'El pulgar izquierdo camina. Arrastra para mirar.', + 'Tap Use to rake the leaves off the drain': 'Toca Usar para quitar las hojas del desagüe', + 'Hold Do to shut the tap': 'Mantén Hacer para cerrar la llave', + 'Still filling': 'Sigue entrando', + 'The Depot': 'El depósito', + 'The storm has gone. The water has not.': 'La tormenta ya pasó. El agua no.', + 'Play': 'Jugar', + 'Jobs': 'Trabajos', + 'Each place is flooded for a reason. Find it, fix it, and get the water down to the green mark.': 'Cada lugar está inundado por una razón. Encuéntrala, arréglala y baja el agua hasta la marca verde.', + 'Use your tool': 'Usar tu herramienta', + 'Hold to turn a tap': 'Mantén para girar una llave', + 'Jump, run': 'Saltar, correr', + 'Scan, journal (after the first job)': 'Escanear, diario (después del primer trabajo)', + 'Again': 'Otra vez', + 'Next': 'Siguiente' }); diff --git a/e63334287a3deaa3/ebbwork/game.js b/e63334287a3deaa3/ebbwork/game.js index 56312f4e..61599b50 100644 --- a/e63334287a3deaa3/ebbwork/game.js +++ b/e63334287a3deaa3/ebbwork/game.js @@ -1,4 +1,5 @@ -/* Flood Crew (first built as Ebbwork): drawing, controls, sound, HUD and menus. The rules of the water and of every tool are in core.js. */ +/* Flood Crew (first built as Ebbwork): drawing, controls, sound, HUD and menus. + The rules of the water and of every tool are in core.js; everything modelled is in models.js. */ (function(){ 'use strict'; var $=function(id){return document.getElementById(id)}; @@ -27,33 +28,45 @@ var GEAR=[ ]; var GEARBY={};GEAR.forEach(function(g){GEARBY[g.id]=g}); var SAVE_KEY='ebbwork:v1'; -var save={v:1,coins:0,gear:{rake:1,bucket:1,wrench:1},load:['rake','bucket','wrench'],jobs:{},set:{sens:1,vol:0.8,q:'auto',inv:0},tut:0}; -(function(){try{var o=JSON.parse(localStorage.getItem(SAVE_KEY)||'null');if(o&&o.v===1){for(var k in o)if(k==='set'||k==='gear'||k==='jobs'){for(var j in o[k])save[k][j]=o[k][j]}else save[k]=o[k]}}catch(e){} +var save={v:1,coins:0,gear:{rake:1,bucket:1,wrench:1},load:['rake','bucket','wrench'],jobs:{},set:{sens:1,vol:0.8,q:'auto',inv:0},tut:0,seen:{}}; +(function(){try{var o=JSON.parse(localStorage.getItem(SAVE_KEY)||'null');if(o&&o.v===1){for(var k in o)if(k==='set'||k==='gear'||k==='jobs'||k==='seen'){for(var j in o[k])save[k][j]=o[k][j]}else save[k]=o[k]}}catch(e){} + // a save from before the rebuilt start (no `seen` in it) already knows the depot: keep its gear bench open + try{var raw=JSON.parse(localStorage.getItem(SAVE_KEY)||'null');if(raw&&!raw.seen&&raw.jobs&&raw.jobs.yard&&raw.jobs.yard.stars)save.seen.shop=save.seen.shopSaid=1}catch(e){} if(!Array.isArray(save.load))save.load=['rake','bucket','wrench'];save.load=save.load.filter(function(t){return GEARBY[t]&&GEARBY[t].slot&&save.gear[t]})})(); function persist(){try{localStorage.setItem(SAVE_KEY,JSON.stringify(save))}catch(e){}} function slots(){return save.gear.rack?7:5} +function owned(){return GEAR.filter(function(g){return g.slot&&save.gear[g.id]}).map(function(g){return g.id})} function unlocked(k){return k===0||!!(save.jobs[EWMaps[k-1].id]&&save.jobs[EWMaps[k-1].id].stars)} +// What a new player has not met yet stays out of sight. Each of these turns on when it starts to matter. +function firstJob(){return !(save.jobs.yard&&save.jobs.yard.stars)} +function shopOpen(){if(save.seen.shop)return true;if(save.jobs.street&&save.jobs.street.stars){save.seen.shop=1;persist();return true}return false} // the gear bench arrives after the second job +function vanNeeded(){return owned().length>slots()} -// ---------------------------------------------------------------- renderer +// ---------------------------------------------------------------- renderer, light and sky var touchUI=matchMedia('(pointer: coarse)').matches&&!matchMedia('(any-pointer: fine)').matches; function setTouch(on){touchUI=on;document.body.classList.toggle('touch',on)} setTouch(touchUI); var canvas=$('view'); var renderer=new THREE.WebGLRenderer({canvas:canvas,antialias:!touchUI,powerPreference:'high-performance'}); -var scene=new THREE.Scene(),camera=new THREE.PerspectiveCamera(74,1,0.06,260); +renderer.shadowMap.enabled=true;renderer.shadowMap.type=THREE.PCFShadowMap;renderer.shadowMap.autoUpdate=false;renderer.localClippingEnabled=true; // the site is still, so its shadows are drawn once and again only when something is put down +var scene=new THREE.Scene(),camera=new THREE.PerspectiveCamera(74,1,0.06,320); camera.rotation.order='YXZ';scene.add(camera); -var SKY={zen:new THREE.Color(0x6c92b4),hor:new THREE.Color(0xcfd8d6),fog:new THREE.Color(0xc3cecd),sun:new THREE.Vector3(-0.45,0.72,0.52).normalize(),sunC:new THREE.Color(0xfff0d8),gnd:new THREE.Color(0x56605a)}; -scene.background=SKY.fog;scene.fog=new THREE.Fog(0xc3cecd,30,170); -var hemi=new THREE.HemisphereLight(0xd3dde2,0x525c50,0.82);scene.add(hemi); -var sun=new THREE.DirectionalLight(0xfff0d8,0.7);sun.position.copy(SKY.sun).multiplyScalar(50);scene.add(sun); -var torch=new THREE.PointLight(0xffe9c4,0,16,1);camera.add(torch); +// late afternoon after the storm: a low warm sun, cool sky fill, long soft shadows +var SKY={zen:new THREE.Color(0x4f86c0),hor:new THREE.Color(0xf3dfbd),fog:new THREE.Color(0xe9dcc4),sun:new THREE.Vector3(-0.62,0.50,0.60).normalize(),sunC:new THREE.Color(0xffd7a0),gnd:new THREE.Color(0x6b6048)}; +scene.background=SKY.fog;scene.fog=new THREE.Fog(0xe9dcc4,45,210); +var hemi=new THREE.HemisphereLight(0xc4d6ea,0x7a6a4c,0.6);scene.add(hemi); +var sun=new THREE.DirectionalLight(0xffd7a0,0.95);sun.castShadow=true;sun.shadow.bias=-0.0006;sun.shadow.normalBias=0.035;scene.add(sun);scene.add(sun.target); +var torch=new THREE.PointLight(0xffe9c4,0,18,1);camera.add(torch); // Auto starts High on computers and Low on touch screens and Chromebooks, and steps down for the rest of the visit // (never back up) if frames stay slow even after ../autores.js has lowered the resolution. -var autoLow=/CrOS/.test(navigator.userAgent),slowN=0,fpsT=0,fpsN=0; +var autoLow=/CrOS/.test(navigator.userAgent),mirrorOff=false,slowN=0,fpsT=0,fpsN=0; // mirrorOff: the next step down after Low, for slow phones: the water stops mirroring the site and shows the sky function quality(){var q=save.set.q;return q==='auto'?(touchUI||autoLow?'low':'high'):q} -function resize(){var w=innerWidth,h=innerHeight,pr=Math.min(devicePixelRatio||1,quality()==='high'?2:touchUI?1.25:1); +function resize(){var w=innerWidth,h=innerHeight,pr=Math.min(devicePixelRatio||1,quality()==='high'||touchUI?2:1); // phones ask for up to 2 so that ../autores.js, which can halve it, never takes them under 1 renderer.setPixelRatio(pr);renderer.setSize(w,h,false);camera.aspect=w/h;camera.fov=w0.02){vec2 q=vW.xz/vP;vec2 f=abs(fract(q)-0.5);float j=smoothstep(0.455,0.492,max(f.x,f.y));vec2 id=floor(q);float h=fract(sin(dot(id,vec2(12.9898,78.233)))*43758.5453);c*=(0.93+0.12*h)*(1.0-0.38*j);}'+ - 'float wet=clamp(vWet,0.0,1.0);c*=mix(1.0,0.60,wet);'+ - 'float dl=max(dot(n,uSun),0.0);vec3 col=c*(mix(uGnd,uSky,n.y*0.5+0.5)*1.05+uSunC*dl*0.62);'+ - 'vec3 V=normalize(uCam-vW);float fr=pow(1.0-max(dot(n,V),0.0),4.0);col+=uSky*fr*wet*0.30;'+ - TORCHF+'col+=c*vec3(1.0,0.92,0.78)*tl*max(dot(n,V),0.2);'+ - 'gl_FragColor=vec4(col,1.0);'+FOGF+'}'}); +// The ground is three's own lit material (so it takes the sun's shadows and the torch), with our patterns added: +// grain, paving joints, and wet ground that is darker and shines until it dries. +var terrainMat=new THREE.MeshLambertMaterial({vertexColors:true}); +terrainMat.onBeforeCompile=function(sh){sh.uniforms.tN=U.tN;sh.uniforms.uHorC=U.uHor; + sh.vertexShader=sh.vertexShader.replace('#include ','attribute float aPat;attribute float aWet;varying float vPat;varying float vWet;varying vec3 vWp;\n#include ').replace('#include ','#include \nvPat=aPat;vWet=aWet;vWp=position;'); + sh.fragmentShader=sh.fragmentShader.replace('#include ','uniform sampler2D tN;uniform vec3 uHorC;varying float vPat;varying float vWet;varying vec3 vWp;\n#include ') + .replace('#include ','#include \nvec3 g_=texture2D(tN,vWp.xz*0.43).rgb;float big_=texture2D(tN,vWp.xz*0.071+0.3).b;diffuseColor.rgb*=(0.80+0.34*g_.b)*(0.84+0.32*big_);'+ + 'if(vPat>0.02){vec2 q_=vWp.xz/vPat;vec2 f_=abs(fract(q_)-0.5);float j_=smoothstep(0.455,0.492,max(f_.x,f_.y));vec2 id_=floor(q_);float h_=fract(sin(dot(id_,vec2(12.9898,78.233)))*43758.5453);diffuseColor.rgb*=(0.90+0.18*h_)*(1.0-0.45*j_);}'+ + 'else{diffuseColor.rgb*=0.86+0.34*texture2D(tN,vWp.xz*1.9).r;}'+ + 'float wet_=clamp(vWet,0.0,1.0);diffuseColor.rgb*=mix(1.0,0.52,wet_);') + .replace('#include ','#include \nfloat fr_=pow(1.0-abs(dot(normalize(vNormal),normalize(vViewPosition))),3.0);totalEmissiveRadiance+=uHorC*fr_*wet_*0.38;')}; +// The water. Brown where it is deep, clear where it is thin, a pale moving line where it meets the ground, ripples that +// run with the current, and the sky (or on High, a mirror picture of the site) on its surface. var waterMat=new THREE.ShaderMaterial({uniforms:U,transparent:true,depthWrite:false,polygonOffset:true,polygonOffsetFactor:-1,polygonOffsetUnits:-3, vertexShader:'attribute float aDepth;attribute vec2 aFlow;uniform mat4 uReflVP;varying float vD;varying vec2 vF;varying vec3 vW;varying vec4 vR;'+ 'void main(){vD=aDepth;vF=aFlow;vW=position;vR=uReflVP*vec4(position,1.0);gl_Position=projectionMatrix*modelViewMatrix*vec4(position,1.0);}', fragmentShader:'precision highp float;uniform sampler2D tN,tR;uniform float uT,uScan,uFogN,uFogF,uTorch,uDay,uRefl;uniform vec3 uCam,uSun,uSunC,uSky,uHor,uFog;varying float vD;varying vec2 vF;varying vec3 vW;varying vec4 vR;'+ - 'void main(){if(vD<0.004)discard;'+ - 'vec2 uv=vW.xz*0.33;vec2 fl=clamp(vF,-1.6,1.6)*0.55;float sp=length(vF);'+ + 'void main(){if(vD<0.003)discard;'+ + 'vec2 uv=vW.xz*0.30;vec2 fl=clamp(vF,-1.6,1.6)*0.6;float sp=length(vF);'+ 'float p0=fract(uT*0.35),p1=fract(uT*0.35+0.5);'+ - 'vec3 a=texture2D(tN,uv-fl*p0+vec2(uT*0.013,uT*0.009)).rgb;vec3 b=texture2D(tN,uv*1.07+0.37-fl*p1-vec2(uT*0.011,-uT*0.012)).rgb;'+ - 'vec3 m=mix(a,b,abs(1.0-2.0*p0));vec2 nn=m.xy*2.0-1.0;'+ - 'float calm=smoothstep(0.0,0.05,vD);float amp=(0.17+min(sp,1.2)*0.5)*calm;'+ + 'vec3 a=texture2D(tN,uv-fl*p0+vec2(uT*0.021,uT*0.013)).rgb;vec3 b=texture2D(tN,uv*1.07+0.37-fl*p1-vec2(uT*0.017,-uT*0.019)).rgb;'+ + 'vec3 m=mix(a,b,abs(1.0-2.0*p0));vec3 fine=texture2D(tN,vW.xz*1.3+vec2(-uT*0.05,uT*0.04)).rgb;vec2 nn=(m.xy*2.0-1.0)+(fine.xy*2.0-1.0)*0.35;'+ + 'float calm=smoothstep(0.0,0.04,vD);float amp=(0.20+min(sp,1.2)*0.6)*calm;'+ 'vec3 N=normalize(vec3(nn.x*amp,1.0,nn.y*amp));vec3 V=normalize(uCam-vW);'+ - 'float fres=0.04+0.96*pow(1.0-max(dot(N,V),0.0),4.2);'+ - 'float murk=1.0-exp(-max(vD,0.0)*5.0);'+TORCHF+'float lit=uDay+tl;'+ - 'vec3 body=mix(vec3(0.38,0.44,0.38),vec3(0.24,0.22,0.14),murk)*lit;float al=mix(0.10,0.94,murk);'+ - 'vec3 R=reflect(-V,N);vec3 skyc=mix(uHor,uSky,clamp(R.y*1.5,0.0,1.0))+vec3(0.05,0.07,0.08)*uTorch;'+ + 'float fres=0.08+0.92*pow(1.0-max(dot(N,V),0.0),3.2);'+ + 'float murk=1.0-exp(-max(vD,0.0)*7.5);vec3 tv=uCam-vW;float tl=uTorch*1.5/(1.0+dot(tv,tv)*0.10);float lit=uDay+tl;'+ + 'vec3 body=mix(vec3(0.55,0.44,0.27),vec3(0.38,0.27,0.13),murk)*lit;float al=mix(0.22,0.98,murk);'+ + 'vec3 R=reflect(-V,N);vec3 skyc=mix(uHor,uSky,clamp(R.y*1.25,0.0,1.0));skyc=mix(vec3(0.20,0.21,0.17)*lit,skyc,smoothstep(0.04,0.30,R.y+nn.x*0.05))+vec3(0.05,0.07,0.08)*uTorch;'+ 'if(uRefl>0.5){vec2 ruv=vR.xy/vR.w*0.5+0.5+nn*0.03*calm;skyc=texture2D(tR,clamp(ruv,0.003,0.997)).rgb;}'+ - 'vec3 col=mix(body,skyc,fres);al=mix(al,1.0,fres*0.8);'+ - 'col+=uSunC*pow(max(dot(R,uSun),0.0),140.0)*1.1;col+=vec3(1.0,0.93,0.8)*tl*pow(max(dot(R,V),0.0),10.0)*0.5;'+ - 'float foam=smoothstep(0.22,0.9,sp)*smoothstep(0.52,0.78,m.b)*calm;col=mix(col,vec3(0.93,0.95,0.92)*lit,foam*0.7);al=max(al,foam*0.7);'+ - 'float edge=smoothstep(0.004,0.011,vD)*(1.0-smoothstep(0.011,0.04,vD));col=mix(col,vec3(0.80,0.85,0.82)*lit,edge*0.30);al=max(al,edge*0.42);'+ - 'al*=smoothstep(0.004,0.02,vD);'+ - 'float sc=uScan*step(0.0045,vD)*(0.6+0.4*sin(uT*9.0-length(vW.xz-uCam.xz)*1.6));col=mix(col,vec3(0.25,1.0,0.92),sc*0.8);al=max(al,sc*0.85);'+ + 'vec3 col=mix(body,skyc,fres);al=mix(al,1.0,fres*0.85);'+ + 'float sd=max(dot(R,uSun),0.0);col+=uSunC*(pow(sd,90.0)*1.3+pow(sd,14.0)*0.10*step(0.62,fine.b));col+=vec3(1.0,0.93,0.8)*tl*pow(max(dot(R,V),0.0),10.0)*0.5;'+ + 'float foam=smoothstep(0.18,0.8,sp)*smoothstep(0.50,0.74,m.b)*calm;col=mix(col,vec3(0.95,0.93,0.86)*lit,foam*0.75);al=max(al,foam*0.75);'+ + 'float lap=0.5+0.5*sin(uT*1.7+m.r*9.0);float edge=(1.0-smoothstep(0.006+0.014*lap,0.045+0.025*lap,vD));col=mix(col,vec3(1.0,0.97,0.88)*lit,edge*0.8);al=max(al,edge*0.85);'+ + 'al*=smoothstep(0.003,0.009,vD);'+ + 'float sc=uScan*step(0.009,vD)*(0.6+0.4*sin(uT*9.0-length(vW.xz-uCam.xz)*1.6));col=mix(col,vec3(0.25,1.0,0.92),sc*0.8);al=max(al,sc*0.85);'+ 'gl_FragColor=vec4(col,al);'+FOGF+'}'}); function setEnv(kind){var c=kind==='cellar'; - SKY.fog.setHex(c?0x0d1113:0xc3cecd);SKY.zen.setHex(c?0x1a2023:0x6c92b4);SKY.hor.setHex(c?0x20272a:0xcfd8d6);SKY.gnd.setHex(c?0x14181a:0x5a6258);SKY.sunC.setHex(c?0x000000:0xfff0d8); - scene.fog.color.copy(SKY.fog);scene.fog.near=U.uFogN.value=c?5:30;scene.fog.far=U.uFogF.value=c?30:170;hemi.intensity=c?0.2:0.8;sun.intensity=c?0:0.7;torch.intensity=c?1.25:0;U.uTorch.value=c?1:0;U.uDay.value=c?0.1:1;skyDome.visible=!c} + SKY.fog.setHex(c?0x0d1113:0xe9dcc4);SKY.zen.setHex(c?0x1a2023:0x4f86c0);SKY.hor.setHex(c?0x20272a:0xf3dfbd);SKY.sunC.setHex(c?0x000000:0xffd7a0); + scene.fog.color.copy(SKY.fog);scene.fog.near=U.uFogN.value=c?5:45;scene.fog.far=U.uFogF.value=c?30:210;hemi.intensity=c?0.2:0.6;sun.intensity=c?0:0.95;sun.castShadow=!c;torch.intensity=c?1.3:0;U.uTorch.value=c?1:0;U.uDay.value=c?0.1:1;skyDome.visible=!c} // ---------------------------------------------------------------- a job site, drawn -var world=null,def=null,lv=null; // lv: this job's meshes and buffers -function Batch(tex){this.p=[];this.n=[];this.c=[];this.u=[];this.tex=tex} -Batch.prototype.quad=function(a,b,c,d,nx,ny,nz,col,sh){var p=this.p,n=this.n,cc=this.c,u=this.u,r=((col>>16)&255)/255*sh,g=((col>>8)&255)/255*sh,bl=(col&255)/255*sh,v=[a,b,c,a,c,d]; - for(var k=0;k<6;k++){var q=v[k];p.push(q[0],q[1],q[2]);n.push(nx,ny,nz);cc.push(r,g,bl);if(ny!==0)u.push(q[0]*0.8,q[2]*0.8);else u.push((nx!==0?q[2]:q[0])*0.8,q[1]*0.8)}}; -Batch.prototype.box=function(x0,y0,z0,x1,y1,z1,col){ - this.quad([x0,y1,z1],[x1,y1,z1],[x1,y1,z0],[x0,y1,z0],0,1,0,col,1.08); - this.quad([x0,y0,z1],[x1,y0,z1],[x1,y1,z1],[x0,y1,z1],0,0,1,col,1); - this.quad([x1,y0,z0],[x0,y0,z0],[x0,y1,z0],[x1,y1,z0],0,0,-1,col,0.9); - this.quad([x1,y0,z1],[x1,y0,z0],[x1,y1,z0],[x1,y1,z1],1,0,0,col,0.96); - this.quad([x0,y0,z0],[x0,y0,z1],[x0,y1,z1],[x0,y1,z0],-1,0,0,col,0.86); - this.quad([x0,y0,z0],[x1,y0,z0],[x1,y0,z1],[x0,y0,z1],0,-1,0,col,0.6)}; -Batch.prototype.mesh=function(){var g=new THREE.BufferGeometry();g.setAttribute('position',new THREE.Float32BufferAttribute(this.p,3));g.setAttribute('normal',new THREE.Float32BufferAttribute(this.n,3));g.setAttribute('color',new THREE.Float32BufferAttribute(this.c,3));g.setAttribute('uv',new THREE.Float32BufferAttribute(this.u,2)); - return new THREE.Mesh(g,new THREE.MeshLambertMaterial({vertexColors:true,map:this.tex||null}))}; -// brickwork and a plain grain, drawn once; walls are tinted by their own colour -function grainTex(brick){var N=256,c=document.createElement('canvas');c.width=c.height=N;var x=c.getContext('2d');x.fillStyle='#ececec';x.fillRect(0,0,N,N);var k,r=(function(a){return function(){a=(a*16807)%2147483647;return a/2147483647}})(brick?77:191); - if(brick){for(var row=0;row<16;row++)for(var cl=0;cl<5;cl++){var v=206+Math.floor(r()*44),bx=cl*64-(row%2?32:0);x.fillStyle='rgb('+v+','+v+','+v+')';x.fillRect(bx+2,row*16+2,60,12);if(bx<0)x.fillRect(bx+N+2,row*16+2,60,12)}} - for(k=0;k<2600;k++){var q=r();x.fillStyle=q<0.5?'rgba(0,0,0,'+(0.03+r()*0.05)+')':'rgba(255,255,255,'+(0.03+r()*0.06)+')';x.fillRect(r()*N,r()*N,1+r()*(brick?3:5),1+r()*2)} - if(!brick)for(k=0;k<26;k++){x.fillStyle='rgba(0,0,0,'+(0.02+r()*0.035)+')';x.fillRect(0,r()*N,N,1+r()*2)} - var t=new THREE.CanvasTexture(c);t.wrapS=t.wrapT=THREE.RepeatWrapping;t.anisotropy=4;return t} -var brickTex=grainTex(true),plainTex=grainTex(false); -var TYPECOL=[[0.37,0.50,0.24],[0.60,0.59,0.55],[0.33,0.25,0.18],[0.70,0.71,0.68],[0.27,0.28,0.30],[0.52,0.49,0.44],[0.56,0.56,0.54]],TYPEPAT=[0,0.75,0,0.4,0,0,2.5]; -function shade(col,f){var r=Math.min(255,((col>>16)&255)*f)|0,g=Math.min(255,((col>>8)&255)*f)|0,b=Math.min(255,(col&255)*f)|0;return r<<16|g<<8|b} - -function drawBox(M,P,b){var B=P,x0=b.x0,x1=b.x1,z0=b.z0,z1=b.z1,y0=b.y0,y1=b.y1,c=b.col,k,i,kd=b.kind; - if(kd==='house'||kd==='houseN'){var N=kd==='houseN',zf=N?z0:z1,s=N?-1:1;M.box(x0,y0,z0,x1,y1,z1,c);B.box(x0-0.25,y1,z0-0.25,x1+0.25,y1+0.22,z1+0.25,0x4a4f55);B.box(x0+0.6,y1+0.22,z0+0.5,x1-0.6,y1+1.3,z1-0.4,0x3f444a); - var gy=y0+0.6;var fb=function(xa,ya,xb,yb,d,col){B.box(xa,ya,Math.min(zf,zf+s*d),xb,yb,Math.max(zf,zf+s*d),col)}; - fb(x0,gy,x1,gy+0.32,0.04,shade(c,0.72)); - for(k=x0+2.2;k4.6){fb(k,gy+3.3,k+1.5,gy+4.4,0.05,0x2a3a48);fb(k-0.08,gy+3.22,k+1.58,gy+3.3,0.09,0xe9e6dc)}} - fb(x1-2.6,gy,x1-1.6,gy+2.05,0.06,0x7d3b2c); - }else if(kd==='fence'){M.box(x0,y0,z0,x1,y1-0.1,z1,c);B.box(x0-0.04,y1-0.1,z0-0.04,x1+0.04,y1,z1+0.04,0x8d8a82); - var lx=x1-x0>z1-z0,len=lx?x1-x0:z1-z0;for(k=1.5;kz1-z0,ln=lh?x1-x0:z1-z0;for(k=0;kz1-z0;if(lr){B.box(x0,y1-0.07,z0+0.2,x1,y1,z1-0.2,c);B.box(x0,y0+0.95,z0+0.22,x1,y0+1.0,z1-0.22,c);for(k=x0;k<=x1-0.1;k+=1.5)B.box(k,y0,z0+0.2,k+0.08,y1,z1-0.2,c)}else{B.box(x0+0.2,y1-0.07,z0,x1-0.2,y1,z1,c);B.box(x0+0.22,y0+0.95,z0,x1-0.22,y0+1.0,z1,c);for(k=z0;k<=z1-0.1;k+=1.5)B.box(x0+0.2,y0,k,x1-0.2,y1,k+0.08,c)} - }else if(kd==='barrier'){B.box(x0,y0,z0+0.15,x1,y1,z1-0.15,c);for(k=x0;k=0&&zz>=0&&xx0.3)cnt++}ao[z*W+x]=1-0.3*Math.min(1,cnt/3)} - L.vert=function(i){var x=i%W,z=(i/W)|0,g=S.g,gl=g[x>0?i-1:i],gr=g[x0?i-W:i],gd=g[z=0?world.S.bar[i]:0)+lift; - if(k===0&&ay!=null)gy=ay;if(k===n&&by!=null)gy=by;out.push(new THREE.Vector3(x,gy,z))}return out} -function rebuildDyn(){ - dynDirty=false;if(lv.dyn){lv.grp.remove(lv.dyn);disposeTree(lv.dyn)} - var g=lv.dyn=new THREE.Group(),B=new Batch(plainTex),S=world.S;lv.gush=[]; - world.barriers.forEach(function(b){b.cells.forEach(function(i,k){var x=world.cx(i),z=world.cz(i),y=S.g[i];B.box(x-0.27,y-0.05,z-0.27,x+0.27,y+0.19,z+0.27,k%2?0xb39b6b:0xa88f5e);B.box(x-0.23,y+0.19,z-0.23,x+0.23,y+0.36,z+0.23,k%2?0xa88f5e:0xbba473)})}); - world.gens.forEach(function(gn){var y=S.g[gn.i],x=gn.x,z=gn.z;B.box(x-0.3,y+0.1,z-0.2,x+0.3,y+0.5,z+0.2,0xe0b21c);B.box(x-0.34,y,z-0.24,x-0.3,y+0.58,z+0.24,0x2f3639);B.box(x+0.3,y,z-0.24,x+0.34,y+0.58,z+0.24,0x2f3639);B.box(x-0.34,y+0.54,z-0.24,x+0.34,y+0.58,z+0.24,0x2f3639);B.box(x-0.1,y+0.5,z-0.08,x+0.1,y+0.56,z+0.08,0xc8362b)}); - world.pumps.forEach(function(p){var y=S.g[p.i];B.box(p.x-0.24,y,p.z-0.18,p.x+0.24,y+0.3,p.z+0.18,0xe0701c);B.box(p.x-0.12,y+0.3,p.z-0.12,p.x+0.12,y+0.42,p.z+0.12,0x2f3639);B.box(p.x-0.22,y+0.42,p.z-0.02,p.x+0.22,y+0.46,p.z+0.02,0x2f3639); - if(p.hose){var hy=world.groundAt(p.hose.x,p.hose.z)+0.12;g.add(tube(linePts(p.x,p.z,p.hose.x,p.hose.z,y+0.2,hy,0.06),0.05,0x2a6f8f)); - var N=26,pp=new Float32Array(N*3),pg=new THREE.BufferGeometry();pg.setAttribute('position',new THREE.BufferAttribute(pp,3));var pts=new THREE.Points(pg,new THREE.PointsMaterial({color:0xe6f3f4,size:0.09,transparent:true,opacity:0.9,depthWrite:false}));pts.frustumCulled=false;pts.position.set(p.hose.x,hy,p.hose.z); - var dx=p.hose.x-p.x,dz=p.hose.z-p.z,dl=Math.hypot(dx,dz)||1;g.add(pts);lv.gush.push({p:p,pts:pts,pp:pp,dx:dx/dl,dz:dz/dl})} - if(p.src){var sy=p.src.gen?S.g[p.src.i]+0.3:world.groundAt(p.src.x,p.src.z)+p.src.y;g.add(tube(linePts(p.x,p.z,p.src.x,p.src.z,y+0.3,sy,0.03),0.018,0x17191b))}}); - g.add(B.mesh());lv.grp.add(g); -} - -// a mirror picture of the site for the water to reflect (High graphics only): the scene drawn once more from under the water level -var reflRT=null,reflCam=new THREE.PerspectiveCamera(),reflPlane=new THREE.Plane(new THREE.Vector3(0,1,0),0),waterH=0,waterHT=0; +var world=null,def=null,lv=null,dynDirty=false,dynEnds=[]; +function rebuildDyn(){dynDirty=false;if(lv.dyn){lv.grp.remove(lv.dyn);EWLook.dispose(lv.dyn,[lv.mats.plain])}var d=EWLook.dyn(world,lv);lv.dyn=d.grp;dynEnds=d.ends;lv.grp.add(d.grp);renderer.shadowMap.needsUpdate=true} +// A mirror picture of the site for the water to reflect: the scene drawn once more from under the water level. It is what +// makes the water read as water, so every tier gets it: 512 x 320 every frame on High, 256 x 160 every other frame on Low. +var reflN=0,reflSize=0,reflRT=null,reflCam=new THREE.PerspectiveCamera(),reflPlane=new THREE.Plane(new THREE.Vector3(0,1,0),1e4),waterH=0,waterHT=0; // the plane sits on the walls' materials all the time; it only bites during the mirror pass function renderReflection(){ - if(quality()!=='high'||!lv){U.uRefl.value=0;return} - if(!reflRT){reflRT=new THREE.WebGLRenderTarget(512,320);U.tR.value=reflRT.texture} - reflCam.fov=camera.fov;reflCam.aspect=camera.aspect;reflCam.near=0.1;reflCam.far=260;reflCam.updateProjectionMatrix(); - reflCam.position.set(camera.position.x,2*waterH-camera.position.y,camera.position.z);reflCam.rotation.order='YXZ';reflCam.rotation.set(-pl.pitch,pl.yaw,0);reflCam.updateMatrixWorld(true); + if(!lv||(mirrorOff&&save.set.q==='auto')){U.uRefl.value=0;return}var hi=quality()==='high',sz=hi?512:256; + if(!hi&&(reflN++&1)&&reflRT)return; + if(!reflRT||reflSize!==sz){if(reflRT)reflRT.dispose();reflRT=new THREE.WebGLRenderTarget(sz,sz*0.625);reflSize=sz;U.tR.value=reflRT.texture} + reflCam.fov=camera.fov;reflCam.aspect=camera.aspect;reflCam.near=0.1;reflCam.far=320;reflCam.updateProjectionMatrix(); + reflCam.position.set(camera.position.x,2*waterH-camera.position.y,camera.position.z);reflCam.rotation.order='YXZ';reflCam.rotation.set(-camera.rotation.x,camera.rotation.y,0);reflCam.updateMatrixWorld(true); reflCam.matrixWorldInverse.copy(reflCam.matrixWorld).invert();U.uReflVP.value.multiplyMatrices(reflCam.projectionMatrix,reflCam.matrixWorldInverse); - reflPlane.constant=-(waterH+0.02);renderer.clippingPlanes=[reflPlane];lv.wm.visible=false;vm.visible=false;ghost.visible=false;U.uRefl.value=0; + reflPlane.constant=-(waterH+0.02);lv.wm.visible=false;var hv=hands.root.visible;hands.root.visible=false;ghost.visible=false;fx.visible=false;U.uRefl.value=0; renderer.setRenderTarget(reflRT);renderer.render(scene,reflCam);renderer.setRenderTarget(null); - renderer.clippingPlanes=[];lv.wm.visible=true;vm.visible=true;ghost.visible=true;U.uRefl.value=1; + reflPlane.constant=1e4;lv.wm.visible=true;hands.root.visible=hv;ghost.visible=true;fx.visible=true;U.uRefl.value=1; } var vv=[0,0],dummy=new THREE.Object3D(); function updateWaterMesh(){ - var S=world.S,W=lv.W,H=lv.H,g=S.g,bar=S.bar,d=S.d,solid=S.solid,wp=lv.wp,wd=lv.wd,wf=lv.wf,wet=lv.wet,x,z,i,j,hs=0,hw=0; + var S=world.S,W=lv.W,H=lv.H,g=S.g,bar=S.bar,d=S.d,solid=S.solid,wp=lv.wp,wd=lv.wd,wf=lv.wf,wet=lv.wet,x,z,i,j,hs=0,hw=0,k; for(z=0;z0.03&&world.mask[i]){var wq=dd/(1+((x*CS-pl.x)*(x*CS-pl.x)+(z*CS-pl.z)*(z*CS-pl.z))*0.02);hs+=(zb+dd)*wq;hw+=wq} - if(!solid[i]&&dd>0.0015){wp[i*3+1]=zb+dd;wd[i]=dd;S.vel(i,vv);wf[i*2]=vv[0];wf[i*2+1]=vv[1];if(wet[i]<1)wet[i]=Math.min(1,wet[i]+0.2)} + if(!solid[i]&&dd>0.0015){wp[i*3+1]=zb+dd;wd[i]=dd;S.vel(i,vv);wf[i*2]=vv[0];wf[i*2+1]=vv[1];wet[i]=1} else{var s=0,sd=0,c=0;for(var oz=-1;oz<=1;oz++){var zz=z+oz;if(zz<0||zz>=H)continue;for(var ox=-1;ox<=1;ox++){var xx=x+ox;if(xx<0||xx>=W)continue;j=zz*W+xx;if(!solid[j]&&d[j]>0.004){s+=g[j]+bar[j]+d[j];sd+=d[j];c++}}} if(c){var y=s/c;wp[i*3+1]=y;wd[i]=solid[i]?sd/c:Math.min(y-zb,0.012)}else{wp[i*3+1]=zb-0.03;wd[i]=-0.03} - wf[i*2]=0;wf[i*2+1]=0;if(wet[i]>0)wet[i]=Math.max(0,wet[i]-0.0006)} + wf[i*2]=0;wf[i*2+1]=0;if(wet[i]>0)wet[i]=Math.max(0,wet[i]-0.0011)} // ground the water has left stays dark for about half a minute } + // a working drain pulls a dip into the surface above it + for(k=0;k=W||z>=H)continue;i=z*W+x;if(wd[i]<=0.01)continue;var ex=(x+0.5)*CS-dr.x,ez=(z+0.5)*CS-dr.z;wp[i*3+1]-=Math.min(wd[i]*0.7,dr.flow*0.42/(0.22+ex*ex+ez*ez))}} if(hw>0)waterHT=hs/hw;waterH+=(waterHT-waterH)*0.15; lv.wg.attributes.position.needsUpdate=true;lv.wg.attributes.aDepth.needsUpdate=true;lv.wg.attributes.aFlow.needsUpdate=true;lv.tg.attributes.aWet.needsUpdate=true; - if(world.dirty.length){var seen={};world.dirty.forEach(function(i){[i,i-1,i+1,i-W,i+W].forEach(function(k){if(k>=0&&k=0&&k=1){best=rings[k];break}else if(rings[k].t>best.t)best=rings[k];best.t=0;best.s=size||1;best.d=dur||0.9;best.m.position.set(x,y+0.012,z);best.m.visible=true} +var ND=160,dropP=new Float32Array(ND*3),dropV=new Float32Array(ND*3),dropL=new Float32Array(ND),dropC=new Float32Array(ND*3),dropK=0,dropGeo=new THREE.BufferGeometry(); +dropGeo.setAttribute('position',new THREE.BufferAttribute(dropP,3));dropGeo.setAttribute('color',new THREE.BufferAttribute(dropC,3)); +var drops=new THREE.Points(dropGeo,new THREE.PointsMaterial({size:0.075,vertexColors:true,transparent:true,opacity:0.95,depthWrite:false}));drops.frustumCulled=false;fx.add(drops); +for(var dk=0;dk=0&&!S.solid[i]&&S.d[i]>0.03){S.vel(i,vv);var near=false;for(var q=0;q0.01&&Math.hypot(dr.x-x,dr.z-z)<3.5)near=true}if(!near&&vv[0]*vv[0]+vv[1]*vv[1]<0.0036)continue;fleckP[k*3]=x;fleckP[k*3+2]=z;fleckA[k]=1.5+Math.random()*3;return}}fleckP[k*3+1]=-99;fleckA[k]=0.4+Math.random()} +function updateFx(dt,time){ + var k,S=world.S; + for(k=0;k=1)continue;r.t+=dt/r.d;if(r.t>=1){r.m.visible=false;continue}var s=r.s*(0.25+r.t*1.25);r.m.scale.set(s,1,s);r.m.material.opacity=(1-r.t)*0.85} + for(k=0;k-50?world.cell(fleckP[k*3],fleckP[k*3+2]):-1; + if(fleckA[k]<=0||i<0||S.solid[i]||S.d[i]<0.02){if(fleckA[k]<=0||i>=0)fleckSpawn(k);continue} + S.vel(i,vv);var px=fleckP[k*3],pz=fleckP[k*3+2]; + for(var q=0;q=0)ring(lx,S.g[li]+S.bar[li]+S.d[li],lz,(l.wrench?0.35:0.7)*L.pow,0.6)}} + for(k=0;k0.004))continue;for(j=0;j<3;j++)drop(G.x,G.y,G.z,G.dx*(1.1+Math.random()*0.5)+(Math.random()-0.5)*0.4,0.7+Math.random()*0.5,G.dz*(1.1+Math.random()*0.5)+(Math.random()-0.5)*0.4,0.5); + G.tick=(G.tick||0)-dt;if(G.tick<=0){G.tick=0.14;var hi=world.cell(G.x+G.dx*0.5,G.z+G.dz*0.5);if(hi>=0)ring(G.x+G.dx*0.5,S.g[hi]+S.bar[hi]+S.d[hi],G.z+G.dz*0.5,0.8,0.6)}} } function updateThings(dt,time){ - var S=world.S,k,j; - for(k=0;k0.02?1:0)} + var S=world.S,k; + for(k=0;k0.015?1:0);var ss=0.6+Math.min(1,d.flow*5)*0.6;o.sw.scale.set(ss,ss,1)} for(k=0;k0.004;if(!G.pts.visible)continue;var gp=G.pp; - for(j=0;j0)p.hop=Math.max(0,p.hop-dt*2.4); + var hp=p.hop>0?Math.sin(p.hop*Math.PI)*0.35:0;dummy.position.set(p.x,p.dy+hp,p.z);dummy.rotation.set((p.fl?Math.sin(time*1.7+k)*0.14:0)+hp*4,p.a,(p.fl?Math.cos(time*1.3+k)*0.14:0)+hp*3);dummy.scale.setScalar(p.sz*(p.k===0?1.25:1));dummy.updateMatrix();p._m.setMatrixAt(p._j,dummy.matrix)} for(k=0;k1){f/=l;s/=l;l=1} var dep=Math.max(0,world.depthAt(pl.x,pl.z)-Math.max(0,pl.y-floorAt(pl.x,pl.z,pl.y))); - var slow=1-Math.min(0.62,dep*(save.gear.waders?0.45:1.25)); + var slow=1-Math.min(0.55,dep*(save.gear.waders?0.4:0.85)); var crouching=inp.crouch;pl.crouch+=((crouching?1:0)-pl.crouch)*Math.min(1,dt*12); var sp=(crouching?1.9:inp.sprint&&f>0.2?5.7:3.7)*slow; - var sy=Math.sin(pl.yaw),cy=Math.cos(pl.yaw),vx=(-sy*f+cy*s)*sp,vz=(-cy*f-sy*s)*sp; + var sy=Math.sin(pl.yaw),cy=Math.cos(pl.yaw),vx=(-sy*f+cy*s)*sp,vz=(-cy*f-sy*s)*sp,ox=pl.x,oz=pl.z; var nx=pl.x+vx*dt;if(!blocked(nx,pl.z,pl.y))pl.x=nx; var nz=pl.z+vz*dt;if(!blocked(pl.x,nz,pl.y))pl.z=nz; + pl.walked+=Math.hypot(pl.x-ox,pl.z-oz); var gy=floorAt(pl.x,pl.z,pl.y); - if(pl.ground){if(inp.jump&&!crouching){pl.vy=4.7*(dep>0.35?0.75:1);pl.ground=false;if(dep>0.05)sfx('splash',0.5)}else if(pl.y-gy>0.32){pl.ground=false}else pl.y+=(gy-pl.y)*Math.min(1,dt*18)} - if(!pl.ground){pl.vy-=15*dt;pl.y+=pl.vy*dt;if(pl.y<=gy){pl.y=gy;pl.ground=true;if(pl.vy<-3)sfx(dep>0.04?'splash':'thud',Math.min(1,-pl.vy/8));pl.vy=0}} + if(pl.ground){if(inp.jump&&!crouching){pl.vy=4.7*(dep>0.35?0.75:1);pl.ground=false;if(dep>0.05){sfx('splash',0.5);splash(pl.x,pl.y+dep,pl.z,8,0.9)}}else if(pl.y-gy>0.32){pl.ground=false}else pl.y+=(gy-pl.y)*Math.min(1,dt*18)} + if(!pl.ground){pl.vy-=15*dt;pl.y+=pl.vy*dt;if(pl.y<=gy){pl.y=gy;pl.ground=true;if(pl.vy<-3){var wet=dep>0.04;sfx(wet?'splash':'thud',Math.min(1,-pl.vy/8));if(wet){splash(pl.x,pl.y+dep,pl.z,14,1.2);ring(pl.x,pl.y+dep,pl.z,1.6,1)}}pl.vy=0}} inp.jump=false; var moving=l>0.1&&pl.ground;pl.speed=moving?sp*l:0; - if(moving){pl.bob+=dt*sp*l*1.9;pl.step+=dt*sp*l;if(pl.step>1.9){pl.step=0;sfx(dep>0.04?'wade':'step',dep>0.04?0.35+Math.min(0.5,dep):0.35)}} - pl.dep=dep; - camera.position.set(pl.x,pl.y+EYE-pl.crouch*0.55+(moving?Math.sin(pl.bob)*0.035:0),pl.z);camera.rotation.set(pl.pitch,pl.yaw,0); + if(moving){pl.bob+=dt*sp*l*1.9;pl.step+=dt*sp*l;if(pl.step>1.5){pl.step=0;var w2=dep>0.03;sfx(w2?'wade':'step',w2?0.35+Math.min(0.5,dep):0.35);if(w2){ring(pl.x-sy*0.3,pl.y+dep,pl.z-cy*0.3,0.9+dep*2,0.9);splash(pl.x-sy*0.3,pl.y+dep,pl.z-cy*0.3,3+Math.round(dep*14),0.55+dep)}}} + pl.dep=dep;if(pl.kick>0)pl.kick=Math.max(0,pl.kick-dt*5); } +function placeCamera(){camera.position.set(pl.x,pl.y+EYE-pl.crouch*0.55+(pl.speed>0?Math.sin(pl.bob)*0.035:0),pl.z);camera.rotation.set(pl.pitch+pl.kick*0.02,pl.yaw,0)} // where the player is pointing on the ground or the water, within reach var aim={x:0,y:0,z:0,i:-1,ok:false,dx:0,dz:0}; function updateAim(reach){ - var cp=Math.cos(pl.pitch),dx=-Math.sin(pl.yaw)*cp,dy=Math.sin(pl.pitch),dz=-Math.cos(pl.yaw)*cp,ox=camera.position.x,oy=camera.position.y,oz=camera.position.z,S=world.S; + var cp=Math.cos(pl.pitch),dx=-Math.sin(pl.yaw)*cp,dy=Math.sin(pl.pitch),dz=-Math.cos(pl.yaw)*cp,ox=pl.x,oy=pl.y+EYE-pl.crouch*0.55,oz=pl.z,S=world.S; aim.dx=-Math.sin(pl.yaw);aim.dz=-Math.cos(pl.yaw);aim.ok=false; for(var t=0.3;t<=reach;t+=0.1){var x=ox+dx*t,y=oy+dy*t,z=oz+dz*t,i=world.cell(x,z);if(i<0)break; if(S.solid[i]&&y=0&&!S.solid[hi]){aim.x=hx;aim.z=hz;aim.y=world.groundAt(hx,hz);aim.i=hi;aim.ok=true}} + if(dy<0.25){var r=Math.min(reach,1.8),hx=ox+aim.dx*r,hz=oz+aim.dz*r,hi=world.cell(hx,hz);if(hi>=0&&!S.solid[hi]){aim.x=hx;aim.z=hz;aim.y=world.groundAt(hx,hz)+S.d[hi];aim.i=hi;aim.ok=true}} } // the nearest fitting the player is looking at var focus=null,hold=0; +function stationOn(kind){return kind==='board'||(kind==='shop'&&shopOpen())||(kind==='van'&&vanNeeded())} function findFocus(){ - var best=null,bs=0.9,cp=Math.cos(pl.pitch),dx=-Math.sin(pl.yaw)*cp,dy=Math.sin(pl.pitch),dz=-Math.cos(pl.yaw)*cp,c=camera.position; - function tryIt(kind,o,x,y,z,reach,wide){var ex=x-c.x,ey=y-c.y,ez=z-c.z,q=Math.sqrt(ex*ex+ey*ey+ez*ez);if(q>reach)return;var dot=(ex*dx+ey*dy+ez*dz)/q+(wide||0);if(dot>bs){bs=dot;best={kind:kind,o:o}}} - world.valves.forEach(function(v){tryIt('valve',v,v.x+v.nx*0.15,world.groundAt(v.x,v.z)+v.y,v.z+v.nz*0.15,2.4)}); + var best=null,bs=0.88,cp=Math.cos(pl.pitch),dx=-Math.sin(pl.yaw)*cp,dy=Math.sin(pl.pitch),dz=-Math.cos(pl.yaw)*cp,c=camera.position; + function tryIt(kind,o,x,y,z,reach,wide){var ex=x-c.x,ey=y-c.y,ez=z-c.z,q=Math.sqrt(ex*ex+ey*ey+ez*ez);if(q>reach)return;var dot=(ex*dx+ey*dy+ez*dz)/q+(wide||0)+(q<1.4?0.4:0);if(dot>bs){bs=dot;best={kind:kind,o:o}}} // right up close, roughly facing it is enough + world.valves.forEach(function(v){tryIt('valve',v,v.x+v.nx*0.15,world.groundAt(v.x,v.z)+v.y,v.z+v.nz*0.15,2.6,0.03)}); world.leaks.forEach(function(l){if(l.wrench&&!l.fixed)tryIt('leak',l,l.px,world.groundAt(l.x,l.z)+l.y,l.pz,2.4)}); world.pumps.forEach(function(p){tryIt('pump',p,p.x,world.S.g[p.i]+0.3,p.z,2.6,0.03)}); - world.stations.forEach(function(s){tryIt('station',s,s.x,world.groundAt(s.x,s.z)+s.y,s.z,3.4,0.06)}); + world.stations.forEach(function(s){if(stationOn(s.kind))tryIt('station',s,s.x,world.groundAt(s.x,s.z)+s.y,s.z,4.2,0.1)}); return best; } // ---------------------------------------------------------------- tools var TOOLS={ - rake:{tip:'Click: push debris away · Right click: pull it to you',ttip:'Use: push debris · Alt: pull it',icon:''}, - bucket:{tip:'Click: fill from water, or tip out · Right click: tip out',ttip:'Use: fill, or tip out',icon:''}, - wrench:{tip:'Hold click on a dripping joint to tighten it',ttip:'Hold Use on a dripping joint',icon:''}, - squeegee:{tip:'Click: push thin water the way you face',ttip:'Use: push thin water forward',icon:''}, - shovel:{tip:'Click: dig soft ground · Right click: put spoil back',ttip:'Use: dig · Alt: put spoil back',icon:''}, - sack:{tip:'Click: bag the debris in front of you for good',ttip:'Use: bag debris for good',icon:''}, - sandbags:{tip:'Click: lay a row · R: turn it · Right click: pick a row up',ttip:'Use: lay a row · Turn · Alt: pick up',icon:''}, - pump:{tip:'Click: put the pump down, then click where the hose should empty · Right click: pick it up',ttip:'Use: place, then point the hose · Alt: pick up',icon:''}, - generator:{tip:'Click: put it down on dry ground · Right click: pick it up',ttip:'Use: put down · Alt: pick up',icon:''} + rake:{alt:0,tip:'Click to rake',ttip:'Use: rake',icon:''}, + bucket:{alt:0,tip:'Click: fill it, or tip it out',ttip:'Use: fill, or tip out',icon:''}, + wrench:{alt:0,tip:'Hold click on a dripping joint',ttip:'Hold Use on a dripping joint',icon:''}, + squeegee:{alt:0,tip:'Click: push thin water forward',ttip:'Use: push thin water forward',icon:''}, + shovel:{alt:1,tip:'Click: dig · Right click: put soil back',ttip:'Use: dig · Alt: put soil back',icon:''}, + sack:{alt:0,tip:'Click: bag the debris in front of you',ttip:'Use: bag debris',icon:''}, + sandbags:{alt:1,tip:'Click: lay a row · R: turn · Right click: pick up',ttip:'Use: lay a row · Alt: pick up',icon:''}, + pump:{alt:1,tip:'Click: put it down, then click where the hose empties · Right click: pick up',ttip:'Use: place, then point the hose · Alt: pick up',icon:''}, + generator:{alt:1,tip:'Click: put it down somewhere dry · Right click: pick up',ttip:'Use: put down · Alt: pick up',icon:''} }; var bar=[],cur=0,bucketVol=0,BUCKET=0.03,swing=0,swingKind=0,useHeld=false,altHeld=false,cool=0,rot=0,inv={},hosePump=null; function tool(){return bar[cur]} -function buildBar(){var h=$('hot');h.innerHTML='';bar.forEach(function(id,k){var t=TOOLS[id],b=document.createElement('button');b.setAttribute('data-no-ad-refresh','');b.setAttribute('aria-label',T(GEARBY[id].name)); +function buildBar(){var h=$('hot');h.innerHTML='';h.classList.toggle('one',bar.length<2);bar.forEach(function(id,k){var t=TOOLS[id],b=document.createElement('button');b.setAttribute('data-no-ad-refresh','');b.setAttribute('aria-label',T(GEARBY[id].name)); b.innerHTML=''+(k+1)+''+t.icon+''+T(GEARBY[id].name)+''; b.addEventListener('click',function(e){e.preventDefault();selectTool(k,true);canvas.focus()});h.appendChild(b)});if(bar.length)selectTool(Math.min(cur,bar.length-1))} function selectTool(k,say){if(k<0||k>=bar.length)return;cur=k;hosePump=null;var bs=$('hot').children;for(var i=0;i0.02){splash(x,y,z,Math.round(6*power),0.9*power);ring(x,y,z,1.1*power,0.8);sfx('splash',0.35*power)}else if(dirt)splash(x,y,z,Math.round(7*power),0.8*power,true)} function useTool(alt){ var id=tool();if(cool>0||!id||state!=='play')return;updateAim(id==='pump'||id==='generator'||id==='sandbags'?3.4:2.6); - if(id==='rake'){swing=0.42;swingKind=alt?2:1;cool=0.42;var px=pl.x,pz=pl.z,dx=aim.dx,dz=aim.dz;setTimeout(function(){if(!world)return;var n=world.rake(px,pz,dx,dz,alt);sfx(n?'rake':'swish',n?0.8:0.4)},130)} + if(alt&&!TOOLS[id].alt)alt=false; + if(id==='rake'){swing=0.42;swingKind=1;cool=0.42;var px=pl.x,pz=pl.z,dx=aim.dx,dz=aim.dz;setTimeout(function(){if(!world||state!=='play')return;var before=world.debris.map(function(p){return p.kick});var n=world.rake(px,pz,dx,dz,false); + world.debris.forEach(function(p,k){if(p.kick>before[k]+0.1)p.hop=1});sfx(n?'rake':'swish',n?0.9:0.4);pl.kick=n?1:0.5;hitFx(px+dx*1.5,pz+dz*1.5,n?1.1:0.7)},130)} else if(id==='bucket'){cool=0.5;swing=0.42;swingKind=1; - if(bucketVol>0.001&&(alt||bucketVol>=BUCKET*0.5||!aim.ok||world.S.d[aim.i]<0.012)){if(!aim.ok){cool=0;return}var v=world.pour(aim.x,aim.z,bucketVol);if(v>0){bucketVol=0;sfx('pour',0.9)}} - else if(!alt&&aim.ok){var got=world.scoop(aim.x,aim.z,BUCKET-bucketVol);if(got>0.0005){bucketVol+=got;sfx('scoop',0.8)}else toast(T('No water to scoop here.'),1.4)}} - else if(id==='squeegee'){cool=0.4;swing=0.42;swingKind=1;var mv=world.squeegee(pl.x,pl.z,aim.dx,aim.dz);sfx(mv>0.0004?'squee':'swish',0.6)} + if(bucketVol>0.001&&(alt||bucketVol>=BUCKET*0.5||!aim.ok||world.S.d[aim.i]<0.012)){if(!aim.ok){cool=0;return}var v=world.pour(aim.x,aim.z,bucketVol);if(v>0){bucketVol=0;sfx('pour',0.9);splash(aim.x,aim.y+0.5,aim.z,16,0.8);ring(aim.x,aim.y,aim.z,1.4,0.9)}} + else if(aim.ok){var got=world.scoop(aim.x,aim.z,BUCKET-bucketVol);if(got>0.0005){bucketVol+=got;sfx('scoop',0.8);ring(aim.x,aim.y,aim.z,1.2,0.8);splash(aim.x,aim.y,aim.z,6,0.7)}else toast(T('No water to scoop here.'),1.4)}} + else if(id==='squeegee'){cool=0.4;swing=0.42;swingKind=1;var mv=world.squeegee(pl.x,pl.z,aim.dx,aim.dz);sfx(mv>0.0004?'squee':'swish',0.6);if(mv>0.0004){splash(pl.x+aim.dx*1.6,world.groundAt(pl.x+aim.dx*1.6,pl.z+aim.dz*1.6)+0.02,pl.z+aim.dz*1.6,7,0.6);pl.kick=0.5}} else if(id==='shovel'){if(!aim.ok||Math.hypot(aim.x-pl.x,aim.z-pl.z)>2.7)return;cool=0.34;swing=0.42;swingKind=1; - if(alt){if(world.pile(aim.x,aim.z))sfx('dig',0.7);else toast(world.spoil>0?T('You cannot pile soil there.'):T('No spoil to put back yet. Dig first.'),1.6)} - else if(world.dig(aim.x,aim.z))sfx('dig',0.9);else{var ci=aim.i;toast(!world.soft[ci]?T('Too hard to dig. Try soil or grass.'):T('That is as deep as this trench will go.'),1.6);sfx('thud',0.4)}} - else if(id==='sack'){cool=0.45;swing=0.42;swingKind=2;if(!aim.ok)return;if(inv.sack<=0){toast(T('The sack is full.'),1.6);return}var got2=world.takeDebris(aim.x,aim.z,1.1,Math.min(6,inv.sack));got2.forEach(function(p){dummy.position.set(0,-50,0);dummy.scale.setScalar(0.001);dummy.updateMatrix();p._m.setMatrixAt(p._j,dummy.matrix)});inv.sack-=got2.length;sfx(got2.length?'rake':'swish',0.6)} + if(alt){if(world.pile(aim.x,aim.z)){sfx('dig',0.7);hitFx(aim.x,aim.z,0.8,true)}else toast(world.spoil>0?T('You cannot pile soil there.'):T('No soil to put back yet. Dig first.'),1.6)} + else if(world.dig(aim.x,aim.z)){sfx('dig',0.9);hitFx(aim.x,aim.z,1,true);pl.kick=1}else{var ci=aim.i;toast(!world.soft[ci]?T('Too hard to dig. Try soil or grass.'):T('That is as deep as this trench will go.'),1.6);sfx('thud',0.4)}} + else if(id==='sack'){cool=0.45;swing=0.42;swingKind=2;if(!aim.ok)return;if(inv.sack<=0){toast(T('The sack is full.'),1.6);return}var got2=world.takeDebris(aim.x,aim.z,1.1,Math.min(6,inv.sack));got2.forEach(function(p){dummy.position.set(0,-50,0);dummy.scale.setScalar(0.001);dummy.updateMatrix();p._m.setMatrixAt(p._j,dummy.matrix)});inv.sack-=got2.length;sfx(got2.length?'rake':'swish',0.6);if(got2.length)hitFx(aim.x,aim.z,0.7)} else if(id==='sandbags'){cool=0.3;if(!aim.ok)return; if(alt){var bb=null,bd=1.3;world.barriers.forEach(function(b){var q=Math.hypot(b.x-aim.x,b.z-aim.z);if(q0.1)toast(T('Too wet. It would drown here.'),1.8); else if(world.placeGen(aim.x,aim.z)){inv.generator--;dynDirty=true;sfx('thud',0.9)}} } +var sway={x:0,y:0,lx:0,ly:0}; function animView(dt){ - var id=tool(),m=vmods[id];if(!m)return;var b=m.userData.base,t=swing>0?1-swing/0.42:0,s=swing>0?Math.sin(t*Math.PI):0,mv=pl.speed>0?1:0; - m.position.set(b.p.x+Math.sin(pl.bob)*0.012*mv,b.p.y+Math.abs(Math.cos(pl.bob))*0.012*mv,b.p.z);m.rotation.set(b.r.x,b.r.y,b.r.z); - if(id==='rake'||id==='squeegee'){m.rotation.x=b.r.x-s*0.45;m.position.z=b.p.z+(swingKind===2?s*0.22:-s*0.3);m.position.y+=-s*0.05} - else if(id==='shovel'){m.rotation.x=b.r.x-s*0.55;m.position.y+=-s*0.14;m.position.z=b.p.z-s*0.12} - else if(id==='bucket'){m.rotation.x=-s*0.9;m.position.y+=s*0.1;m.userData.water.visible=bucketVol>0.002;m.userData.water.position.y=-0.12+0.2*clamp(bucketVol/BUCKET,0,1)} - else if(id==='wrench'){m.rotation.z=b.r.z+(hold>0&&focus&&focus.kind==='leak'?Math.sin(performance.now()*0.012)*0.5:0)} - else m.position.y+=-s*0.08; + var id=tool(),m=hands.mods[id];if(!m)return;var t=swing>0?1-swing/0.42:0,s=swing>0?Math.sin(t*Math.PI):0,mv=pl.speed>0?1:0; + // the hands lag a little behind where you look, and bob as you walk + var dyaw=pl.yaw-sway.lx,dpit=pl.pitch-sway.ly;sway.lx=pl.yaw;sway.ly=pl.pitch;sway.x+=(clamp(dyaw*1.2,-0.06,0.06)-sway.x)*Math.min(1,dt*9);sway.y+=(clamp(dpit*1.2,-0.05,0.05)-sway.y)*Math.min(1,dt*9); + m.position.set(sway.x+Math.sin(pl.bob)*0.012*mv,-sway.y+Math.abs(Math.cos(pl.bob))*0.014*mv-0.01,0);m.rotation.set(0,0,0); + if(id==='rake'||id==='squeegee'){m.rotation.x=-s*0.20;m.position.z=-s*0.26+(swingKind===2?s*0.4:0);m.position.y+=-s*0.06;m.rotation.y=s*0.10} + else if(id==='shovel'){m.rotation.x=-s*0.28;m.position.y+=-s*0.16;m.position.z=-s*0.14} + else if(id==='bucket'){m.rotation.x=-s*0.5;m.position.y+=s*0.12;hands.bucketWater(bucketVol/BUCKET)} + else if(id==='wrench'){m.rotation.z=(hold>0&&focus&&focus.kind==='leak'?Math.sin(performance.now()*0.012)*0.35:0)} + else m.position.y+=-s*0.1; if(swing>0)swing=Math.max(0,swing-dt);if(cool>0)cool-=dt; } @@ -457,17 +362,20 @@ function sfx(n,v){if(!AC||AC.state!=='running')return;v=v==null?1:v; else if(n==='wade'){nz(0.3,'lowpass',1500+Math.random()*600,350,0.26*v)} else if(n==='step'){nz(0.09,'lowpass',500,120,0.2*v)} else if(n==='thud'){tone(0.14,'sine',120,45,0.5*v);nz(0.08,'lowpass',700,150,0.2*v)} - else if(n==='rake'){nz(0.3,'bandpass',2800,1500,0.3*v,3);nz(0.2,'highpass',5200,3800,0.08*v)} + else if(n==='rake'){nz(0.3,'bandpass',2800,1500,0.3*v,3);nz(0.2,'highpass',5200,3800,0.08*v);nz(0.16,'lowpass',900,300,0.12*v)} else if(n==='swish'){nz(0.2,'bandpass',900,2200,0.12*v,1.5)} else if(n==='dig'){tone(0.1,'sine',95,50,0.45*v);nz(0.26,'bandpass',1200,500,0.34*v,1.2)} else if(n==='squee'){nz(0.34,'lowpass',1800,600,0.3*v);tone(0.2,'sine',880,1150,0.03*v)} else if(n==='scoop'){nz(0.36,'lowpass',700,2600,0.36*v)} else if(n==='pour'){nz(0.75,'lowpass',2600,500,0.42*v);nz(0.4,'bandpass',1400,700,0.16*v,2)} else if(n==='gulp'){tone(0.22,'sine',170+Math.random()*60,58,0.4*v);tone(0.16,'sine',240,90,0.2*v,0.11);nz(0.2,'bandpass',420,160,0.18*v,3)} + else if(n==='unblock'){tone(0.5,'sine',150,42,0.6*v);tone(0.3,'sine',260,70,0.3*v,0.12);tone(0.26,'sine',210,60,0.28*v,0.34);nz(0.9,'bandpass',520,150,0.34*v,2.5);nz(1.2,'lowpass',1800,400,0.2*v)} else if(n==='valve'){tone(0.3,'triangle',520,760,0.07*v);tone(0.24,'triangle',660,480,0.06*v,0.22);nz(0.3,'bandpass',2100,1500,0.07*v,6)} + else if(n==='shut'){tone(0.12,'sine',140,60,0.5*v);nz(0.5,'highpass',3000,5000,0.1*v);tone(0.08,'square',300,180,0.05*v,0.1)} else if(n==='tick'){tone(0.05,'square',880,660,0.035*v)} else if(n==='scan'){tone(0.5,'sine',740,1480,0.11*v);tone(0.6,'sine',1110,2220,0.05*v,0.1)} else if(n==='buy'){tone(0.12,'triangle',660,660,0.14*v);tone(0.2,'triangle',990,990,0.14*v,0.1)} + else if(n==='good'){tone(0.18,'triangle',660,660,0.1*v);tone(0.3,'triangle',880,880,0.1*v,0.12)} else if(n==='done'){[523,659,784,1047].forEach(function(f,k){tone(0.5,'triangle',f,f,0.16*v,k*0.13)})} } function audioTick(){if(!AC)return;var on=state==='play'&&world,now=AC.currentTime,tc=0.25; @@ -476,75 +384,77 @@ function audioTick(){if(!AC)return;var on=state==='play'&&world,now=AC.currentTi var fr=clamp(world.left/Math.max(1,world.start||1),0,1.2),cellar=def.sky==='cellar'; set('air',cellar?0.02:0.05);set('lap',0.012+0.075*Math.sqrt(fr)+Math.min(0.08,pl.speed*pl.dep*0.12)); var fl=0,k,q;for(k=0;k0.01&&world.S.d[d.i]<0.07&&q<12&&world.t-lastGulp>0.9+Math.random()*1.6){lastGulp=world.t;sfx('gulp',0.9/(1+q*0.12))}} + if(d.flow>0.01&&q<14&&world.t-lastGulp>(world.S.d[d.i]<0.07?0.8:2.2)+Math.random()*1.6){lastGulp=world.t;sfx('gulp',(world.S.d[d.i]<0.07?0.9:0.5)/(1+q*0.12))}} for(k=0;k0.03){q=Math.hypot(l.x-pl.x,l.z-pl.z);lk+=(l.wrench?0.35:1)*L.pow/(1+q*q*0.05)}}set('leak',Math.min(0.13,lk*0.12)); var pm=0;for(k=0;k0||def.depot)return;scanT=4.5;scanCool=9;$('scanfx').classList.add('on');sfx('scan',0.7); - toast(world.left>0.004?T('{v} litres still lying here, over {n} square metres.',{v:Math.round(world.left*1000),n:Math.round(world.wet*0.25)}):T('No standing water found.'),3.5)} +function scan(){if(state!=='play'||scanCool>0||def.depot||firstJob())return;scanT=4.5;scanCool=9;$('scanfx').classList.add('on');sfx('scan',0.7); + toast(world.left>0.004?T('{v} litres still lying here.',{v:Math.round(world.left*1000)}):T('No standing water found.'),3.5)} function tasks(){ var out=[],w=world; w.drains.forEach(function(d,k){var found=seen['d'+k];if(!found)out.push({t:T('Find where this water should be draining to'),s:T('Low points are a good place to look.'),done:false}); else out.push({t:d.kind==='culvert'?T('Keep the culvert clear'):T('Keep the drain clear'),s:d.clear>=0.9?T('Running freely.'):T('{p}% blocked. Rake the debris well away, or it will wash back.',{p:Math.round((1-d.clear)*100)}),done:d.clear>=0.9})}); w.leaks.forEach(function(l,k){var found=seen['l'+k];if(!found&&l.on)out.push({t:T('Find out if water is still getting in'),s:T('Listen, and look along the walls.'),done:false}); - else out.push({t:T('Stop the leak'),s:l.on?(l.valve?T('The pipe is under pressure. Follow it back to a stop tap.'):T('A dripping joint. Tighten it with the wrench.')):T('Stopped.'),done:!l.on})}); + else out.push({t:T('Stop the leak'),s:l.on?(l.valve?T('Follow its pipe back to a tap.'):T('A dripping joint. Tighten it with the wrench.')):T('Stopped.'),done:!l.on})}); if(w.holdList.length){var blk=w.holdIn<=0.004&&w.barriers.length>0;out.push({t:T('Stop the water getting in from outside'),s:blk?T('Held back.'):T('Something has to stand in its way.'),done:blk})} w.pumps.forEach(function(p){out.push({t:T('Pump'),s:pumpWhy(p),done:p.run&&p.away&&p.why===''})}); - var pc=Math.round(w.fraction()*100);out.push({t:T('Get the water under the green mark'),s:T('{p}% left. Small puddles are fine.',{p:pc}),done:w.fraction()<=EW.World.DONE}); + var pc=Math.round(w.fraction()*100);out.push({t:T('Get the water down to the green mark'),s:T('{p}% left. Small puddles are fine.',{p:pc}),done:w.fraction()<=EW.World.DONE}); return out; } function esc(s){return String(s).replace(/[&<>"]/g,function(c){return{'&':'&','<':'<','>':'>','"':'"'}[c]})} -function openJournal(){$('jTitle').textContent=def.name+' · '+T(def.sub);$('jBrief').textContent=T(def.brief); - var h=def.depot?'':tasks().map(function(t){return'
  • '+esc(t.t)+''+esc(t.s)+'
  • '}).join(''); +function openJournal(){$('jTitle').textContent=def.name;$('jBrief').textContent=T(def.brief); + var h=tasks().map(function(t){return'
  • '+esc(t.t)+''+esc(t.s)+'
  • '}).join(''); if(notes.length)h+='
  • '+esc(T('What you have noticed'))+notes.map(function(n){return'• '+esc(n)+''}).join('')+'
  • '; - if(def.depot)h+='
  • '+esc(T('The job board has the work, the bench sells gear, and the van takes you there.'))+'
  • '; $('jTasks').innerHTML=h;show('journal')} -// the first job walks a new player through it, one line at a time +// The first job teaches by doing: one short line at a time, gone as soon as it is done. var TUT=[ - {t:'Walk into the yard and look for where the water ought to be going.',ok:function(){return seen.d0}}, - {t:'That is the drain, under the debris. Hold the rake (1) and click to push the debris off it. Push it a long way.',tt:'That is the drain, under the debris. With the rake, tap Use to push the debris off it. Push it a long way.',ok:function(){return world.drains[0].clear>0.85}}, - {t:'Better, but the gauge says water is still coming in. Find what is feeding it.',ok:function(){return seen.l0||!world.incoming()}}, - {t:'A split pipe. It cannot be mended under pressure: follow the pipe along the wall to its stop tap, and hold E on it.',tt:'A split pipe. It cannot be mended under pressure: follow the pipe along the wall to its stop tap, and hold Do on it.',ok:function(){return !world.incoming()}}, - {t:'Now keep the drain clear while it empties. Debris floats back. F shows the water that is left.',tt:'Now keep the drain clear while it empties. Debris floats back. The scan button shows the water that is left.',ok:function(){return world.fraction()<0.2}}, - {t:'Nearly there. The green mark on the gauge is all you need: small puddles do not matter.',ok:function(){return world.isDone()}} -],tutK=-1; + {t:'Move with W A S D. Look with the mouse.',tt:'Left thumb walks. Drag to look.',ok:function(){return pl.walked>2.5}}, + {t:'Find the drain under the leaves',ok:function(){return seen.d0}}, + {t:'Click to rake the leaves off the drain',tt:'Tap Use to rake the leaves off the drain',ok:function(){return world.drains[0].clear>0.85}}, + {t:function(){var v=world.valves[0],nearTap=Math.hypot(v.x-pl.x,v.z-pl.z)<3.4;return nearTap?(touchUI?'Hold Do to shut the tap':'Hold E to shut the tap'):'Water is still pouring in. Follow the copper pipe to its tap'},ok:function(){return !world.incoming()}}, + {t:'Keep the drain clear until the yard is dry',ok:function(){return world.isDone()}} +],tutK=-1,depotSay=''; +var wasClear=[]; function updateHud(dt){ var fr=world.fraction(),k; - if(!def.depot){$('gaugeFill').style.width=clamp(fr*100,0,100).toFixed(1)+'%';$('pct').textContent=Math.round(fr*100)+'%';$('clock').textContent=fmtTime(world.t);$('inflow').hidden=!world.incoming()} - if(toastT>0){toastT-=dt;if(toastT<=0)$('toast').classList.add('off')} + if(!def.depot){$('gaugeFill').style.width=clamp(fr*100,0,100).toFixed(1)+'%';$('pct').textContent=Math.round(fr*100)+'%';$('inflow').hidden=!(world.incoming()&&(tutK<0||tutK>=3))} if(scanT>0){scanT-=dt;if(scanT<=0)$('scanfx').classList.remove('on')}if(scanCool>0)scanCool-=dt; U.uScan.value+=((scanT>0?1:0)-U.uScan.value)*Math.min(1,dt*5); var u=$('hot').children;for(k=0;k0.001?Math.round(bucketVol*1000)+'L':'';else if(inv[id]!=null)tx=String(inv[id]);if(u[k].lastChild.textContent!==tx)u[k].lastChild.textContent=tx} - // things noticed, for the journal and the hints - world.drains.forEach(function(d,k){if(!seen['d'+k]&&Math.hypot(d.x-pl.x,d.z-pl.z)<3.2){seen['d'+k]=1;if(!def.depot)toast(d.clear<0.5?T('A drain, buried in debris. That is one reason the water is staying.'):T('A drain.'),4)}}); - world.leaks.forEach(function(l,k){if(!seen['l'+k]&&l.on&&Math.hypot(l.x-pl.x,l.z-pl.z)<4.2){seen['l'+k]=1;toast(l.wrench?T('A joint is dripping steadily here.'):T('Water is pouring out of a split pipe here. Nothing will drain for long while this runs.'),4.5)}}); - world.spots.forEach(function(s){if(!s.seen&&Math.hypot(s.x-pl.x,s.z-pl.z)=0){if(TUT[tutK].ok()){tutK++;if(tutK>=TUT.length){tutK=-1;save.tut=1;persist()}}} - if(tutK>=0){var tx2=T(touchUI&&TUT[tutK].tt?TUT[tutK].tt:TUT[tutK].t);if(gd.textContent!==tx2)gd.textContent=tx2;gd.hidden=false}else gd.hidden=true; + // things noticed + world.drains.forEach(function(d,k){if(!seen['d'+k]&&Math.hypot(d.x-pl.x,d.z-pl.z)<3.4){seen['d'+k]=1;if(!def.depot&&tutK<0)toast(d.clear<0.5?T('A drain, buried in debris.'):T('A drain.'),3)} + // the moment a blocked drain lets go + if(wasClear[k]===false&&d.clear>=0.55&&world.S.d[d.i]>0.04){wasClear[k]=true;sfx('unblock',1/(1+Math.hypot(d.x-pl.x,d.z-pl.z)*0.08));var y=world.S.g[d.i]+world.S.d[d.i];ring(d.x,y,d.z,2.6,1.3);ring(d.x,y,d.z,1.4,0.9);splash(d.x,y,d.z,18,1.1)}else if(d.clear<0.3)wasClear[k]=false}); + world.leaks.forEach(function(l,k){if(!seen['l'+k]&&l.on&&Math.hypot(l.x-pl.x,l.z-pl.z)<4.2){seen['l'+k]=1;if(tutK<0)toast(l.wrench?T('A joint is dripping steadily here.'):T('Water is pouring out of a split pipe here.'),3.5)}}); + if(tutK<0)world.spots.forEach(function(s){if(!s.seen&&Math.hypot(s.x-pl.x,s.z-pl.z)=0&&TUT[tutK].ok()){tutK++;sfx('good',0.8);if(tutK>=TUT.length){tutK=-1;save.tut=1;persist()}} + if(toastT>0)toastT-=dt; + var tl=tutK>=0?TUT[tutK]:null,line=tl?T(typeof tl.t==='function'?tl.t():touchUI&&tl.tt?tl.tt:tl.t):toastT>0?toastTx:def.depot?depotSay:'',sy=$('say'); + if(sy.textContent!==line){if(line){sy.textContent=line;sy.classList.remove('off');sy.classList.toggle('do',tutK>=0)}else sy.classList.add('off')} // prompt focus=findFocus();var p=$('prompt'),tap=touchUI?T('Do'):'E',act=touchUI?T('Hold Do'):T('Hold E'),txt=''; if(focus){var o=focus.o; - if(focus.kind==='valve')txt=act+': '+(o.closed?T('open the stop tap'):T('shut the stop tap')); + if(focus.kind==='valve')txt=tutK>=0?'':act+': '+(o.closed?T('open the tap'):T('shut the tap')); else if(focus.kind==='leak')txt=tool()==='wrench'?(touchUI?T('Hold Use'):T('Hold click'))+': '+T('tighten the joint'):T('A dripping joint. It needs the wrench.'); else if(focus.kind==='pump')txt=pumpWhy(o)+' '+tap+': '+(o.on?T('switch off'):T('switch on')); - else if(focus.kind==='station')txt=tap+': '+(o.kind==='board'?T('look at the job board'):o.kind==='shop'?T('buy gear'):T('load the van')); - $('promptTx').textContent=txt;p.hidden=false;$('promptBar').hidden=hold<=0;$('promptBar').firstChild.style.width=clamp(hold,0,1)*100+'%'}else{p.hidden=true;hold=0} + else if(focus.kind==='station')txt=tap+': '+(o.kind==='board'?T('pick a job'):o.kind==='shop'?T('buy gear'):T('load the van')); + $('promptTx').textContent=txt;p.hidden=!txt&&hold<=0;$('promptBar').hidden=hold<=0;$('promptBar').firstChild.style.width=clamp(hold,0,1)*100+'%'}else{p.hidden=true;hold=0} $('cross').classList.toggle('act',!!focus);$('tAct').hidden=!(focus&&focus.kind!=='leak'); if(focus&&(inp.act||inp.tap)&&(focus.kind==='pump'||focus.kind==='station')){inp.act=false;if(focus.kind==='pump'){focus.o.on=!focus.o.on;sfx('tick',1)}else openStation(focus.o.kind)} var working=focus&&((focus.kind==='valve'&&inp.act)||(focus.kind==='leak'&&tool()==='wrench'&&useHeld)); - if(working){hold+=dt/(focus.kind==='valve'?1.0:1.8);if(hold>=1){hold=0;inp.act=false;if(focus.kind==='valve'){world.setValve(focus.o,!focus.o.closed);sfx('valve',0.9);toast(focus.o.closed?T('Stop tap shut.'):T('Stop tap open.'),2.2)}else{world.fixLeak(focus.o);sfx('valve',0.8);toast(T('Joint tightened.'),2.2)}}} + if(working){hold+=dt/(focus.kind==='valve'?0.9:1.6);if(Math.random()=1){hold=0;inp.act=false;if(focus.kind==='valve'){world.setValve(focus.o,!focus.o.closed);sfx('shut',1);if(tutK<0)toast(focus.o.closed?T('Tap shut.'):T('Tap open.'),2)}else{world.fixLeak(focus.o);sfx('shut',0.8);toast(T('Joint tightened.'),2)}}} else if(hold>0)hold=Math.max(0,hold-dt*2); inp.tap=false; } @@ -557,36 +467,40 @@ function starsHtml(n){return'★'.repeat(n)+''+'★'.repeat(3-n)+''} function coinsTx(){$('coins').textContent=save.coins+' ◈'} function jobBy(id){return EWMaps.filter(function(m){return m.id===id})[0]} function enter(d){ - if(lv){scene.remove(lv.grp);disposeTree(lv.grp);lv=null} + if(lv){scene.remove(lv.grp);EWLook.dispose(lv.grp,[terrainMat,waterMat]);lv=null} def=d;setEnv(def.sky); - world=new EW.World(def,{hoseLen:save.gear.hose2?16:9,cableLen:save.gear.reel?18:8});lv=buildLevel(world); - pl.x=world.spawn.x;pl.z=world.spawn.z;pl.y=world.groundAt(pl.x,pl.z);pl.yaw=world.spawn.yaw;pl.pitch=0;pl.vy=0;pl.ground=true; - var own=function(t){return save.gear[t]}; - bar=def.depot?GEAR.filter(function(g){return g.slot&&own(g.id)}).map(function(g){return g.id}).slice(0,9):save.load.filter(own); + world=new EW.World(def,{hoseLen:save.gear.hose2?16:9,cableLen:save.gear.reel?18:8});lv=EWLook.level(world,{terrainMat:terrainMat,waterMat:waterMat,T:T,clip:reflPlane});scene.add(lv.grp); + lv.stations.forEach(function(s){s.g.visible=stationOn(s.s.kind)}); + pl.x=world.spawn.x;pl.z=world.spawn.z;pl.y=world.groundAt(pl.x,pl.z);pl.yaw=world.spawn.yaw;pl.pitch=def.depot?0:-0.16;pl.vy=0;pl.ground=true;pl.walked=0;sway.lx=pl.yaw;sway.ly=pl.pitch; + var first=firstJob(),own=owned(); + bar=def.depot?[]:first?['rake']:vanNeeded()?save.load.filter(function(t){return save.gear[t]}):own; inv={};if(bar.indexOf('sandbags')>=0)inv.sandbags=save.gear.bags2?8:4;if(bar.indexOf('pump')>=0)inv.pump=save.gear.pump2?2:1;if(bar.indexOf('generator')>=0)inv.generator=1;if(bar.indexOf('sack')>=0)inv.sack=40; - cur=0;bucketVol=0;seen={};notes=[];endT=0;scanT=0;scanCool=0;hold=0;acc=0;rot=0;hosePump=null;dynDirty=true;inp.crouch=false;$('tCrouch').classList.remove('on'); - buildBar();$('plName').textContent=def.name;$('hud').hidden=false;coinsTx(); - $('statLbl').hidden=$('gauge').hidden=!!def.depot;$('coins').hidden=!def.depot;$('clock').hidden=!!def.depot;$('bScan').hidden=!!def.depot;$('inflow').hidden=true;$('guide').hidden=true; - $('bQuit').hidden=$('bRestart').hidden=!!def.depot;$('bTitle').hidden=!def.depot; - tutK=(!def.depot&&def.id==='yard'&&!save.tut)?0:-1; + cur=0;bucketVol=0;seen={};notes=[];endT=0;scanT=0;scanCool=0;hold=0;acc=0;rot=0;hosePump=null;dynDirty=true;inp.crouch=false;toastT=0;wasClear=world.drains.map(function(dr){return dr.clear>=0.55}); + tutK=(!def.depot&&def.id==='yard'&&first)?0:-1; + buildBar();hands.root.visible=bar.length>0;$('hud').hidden=false;coinsTx(); + $('bar').hidden=!!def.depot;$('place').hidden=!def.depot;$('coins').hidden=!(def.depot&&shopOpen());$('bScan').hidden=$('bJournal').hidden=!!def.depot||first;$('inflow').hidden=true;$('hot').hidden=!bar.length; + $('bQuit').hidden=$('bRestart').hidden=!!def.depot||first;$('bTitle').hidden=!def.depot;$('bJournal2').hidden=!!def.depot||first; if(!def.depot){var r=save.jobs[def.id]||(save.jobs[def.id]={stars:0,best:0,n:0});r.seen=1;persist()} - updateWaterMesh();state='play';show(null);lockPointer(); - toast(def.depot?(selJob?T('Job taken: {j}. Load the van when you are ready.',{j:jobBy(selJob).name}):T('Your depot. The job board is on the wall ahead.')):T(def.brief),5); + depotSay=def.depot?(shopOpen()&&!save.seen.shopSaid?T('You have pay to spend. The gear bench is on the right'):T('Pick your next job from the board')):''; + if(def.depot&&shopOpen()&&!save.seen.shopSaid){save.seen.shopSaid=1;persist()} + fitShadow();updateWaterMesh();for(var k=0;k0,pay=Math.round(def.pay*(0.6+0.2*stars)*(again?0.5:1)); r.n=(r.n||0)+1;r.stars=Math.max(r.stars,stars);r.best=r.best?Math.min(r.best,Math.round(t)):Math.round(t);save.jobs[def.id]=r;save.coins+=pay;persist(); - $('rStars').innerHTML=starsHtml(stars); - $('rSum').innerHTML=''+esc(T('Time'))+''+fmtTime(t)+' ('+esc(T('target'))+' '+fmtTime(def.par)+')'+esc(T('Water left'))+''+(fr*100).toFixed(1)+'%'+esc(again?T('Pay (half: you have done this job before)'):T('Pay'))+''+pay+' ◈'+esc(T('Your coins'))+''+save.coins+' ◈'; - $('guide').hidden=true;show('result');sfx('done',1); + $('rTitle').textContent=T('{p} is dry',{p:def.name});$('rStars').innerHTML=starsHtml(stars); + $('rSum').innerHTML=''+esc(T('Time'))+''+fmtTime(t)+''+esc(again?T('Pay (half for a repeat)'):T('Pay'))+''+pay+' ◈'; + show('result');sfx('done',1); } function pause(){if(state!=='play')return;state='pause';show('pause')} function resume(){if(state!=='pause')return;state='play';show(null);lockPointer()} function toTitle(){state='menu';$('hud').hidden=true;show('menu')} function toDepot(){enter(EWMaps.depot)} +function play(){if(firstJob()){selJob='yard';enter(jobBy('yard'))}else toDepot()} function lockPointer(){if(!touchUI&&canvas.requestPointerLock){try{var p=canvas.requestPointerLock();if(p&&p.catch)p.catch(function(){})}catch(e){}}canvas.focus()} document.addEventListener('pointerlockchange',function(){if(!document.pointerLockElement&&state==='play'&&!touchUI)pause()}); -$('bStart').onclick=toDepot; +$('bStart').onclick=play; $('bResume').onclick=resume;$('bQuit').onclick=toDepot;$('bTitle').onclick=toTitle;$('bRestart').onclick=function(){enter(def)}; $('bAgain').onclick=function(){enter(def)};$('bBack').onclick=toDepot; function openSub(id){if(state==='menu')backTo='menu';else if(state==='play'){state='pause';backTo='play'}else backTo='pause';if(id==='journal')openJournal();else show(id)} @@ -596,21 +510,19 @@ $('bJournal').onclick=$('bJournal2').onclick=function(){openSub('journal')}; $('bSetDone').onclick=$('bHowDone').onclick=$('bJDone').onclick=$('bBoardX').onclick=$('bShopX').onclick=$('bVanX').onclick=closeSub; $('bPause').onclick=pause;$('bScan').onclick=function(){scan();canvas.focus()}; $('bFull').onclick=function(){var d=document;if(d.fullscreenElement)d.exitFullscreen();else if(d.documentElement.requestFullscreen){var p=d.documentElement.requestFullscreen();if(p&&p.catch)p.catch(function(){})}}; -// depot: job board, shop, van +// depot: the job board; later the gear bench; later still, the van var pick=null; -function openStation(kind){backTo='play';state='pause';if(kind==='board'){pick=selJob||EWMaps[0].id;drawBoard();show('board')}else if(kind==='shop'){drawShop();show('shop')}else{drawVan();show('van')}} -function drawBoard(){var h=$('jobList');h.innerHTML='';EWMaps.forEach(function(m,k){var b=document.createElement('button');b.className='job';b.disabled=!unlocked(k);b.setAttribute('aria-pressed',m.id===pick?'true':'false');var r=save.jobs[m.id]; - b.innerHTML='
    '+m.name+''+(unlocked(k)?esc(T(m.sub)):esc(T('Finish {j} first',{j:EWMaps[k-1].name})))+'
    '+starsHtml(r?r.stars:0)+'';b.addEventListener('click',function(){pick=m.id;drawBoard()});h.appendChild(b)}); +function openStation(kind){backTo='play';state='pause';if(kind==='board'){var nxt=EWMaps.filter(function(m,k){return unlocked(k)&&!(save.jobs[m.id]&&save.jobs[m.id].stars)})[0];pick=selJob&&jobBy(selJob)?selJob:(nxt||EWMaps[0]).id;if(nxt)pick=nxt.id;drawBoard();show('board')}else if(kind==='shop'){drawShop();show('shop')}else{drawVan();show('van')}} +function drawBoard(){var h=$('jobList');h.innerHTML='';EWMaps.forEach(function(m,k){var open=unlocked(k),b=document.createElement('button');b.className='job';b.disabled=!open;b.setAttribute('aria-pressed',m.id===pick?'true':'false');var r=save.jobs[m.id]; + b.innerHTML='
    '+(open?m.name:'? ? ?')+''+(open?esc(T(m.sub)):esc(T('Locked')))+'
    '+(open?starsHtml(r?r.stars:0):'')+'';b.addEventListener('click',function(){pick=m.id;drawBoard()});h.appendChild(b)}); var m=jobBy(pick),r=save.jobs[m.id]||{},need=(m.needs||[]).map(function(g){return T(GEARBY[g].name)+(save.gear[g]?'':' ('+T('not owned')+')')}).join(', '); - $('jobInfo').innerHTML='

    '+m.name+'

    '+esc(T(m.brief))+'
    '+esc(T('Pays up to'))+''+Math.round(m.pay*1.2)+' ◈'+esc(T('Target time'))+''+fmtTime(m.par)+''+(r.best?''+esc(T('Your best'))+''+fmtTime(r.best)+'':'')+'
    '+ - '
    '+(r.seen&&need?''+esc(T('From your last visit, worth bringing:'))+' '+esc(need):esc(T('Nobody has looked at it yet. Go and see what it needs; you can always come back for more gear.')))+'
    '+(r.n?'
    '+esc(T('Done before: a repeat pays half.'))+'
    ':''); - $('bTake').disabled=!unlocked(EWMaps.indexOf(m)); -} -$('bTake').onclick=function(){selJob=pick;closeSub();toast(T('Job taken: {j}. Load the van when you are ready.',{j:jobBy(selJob).name}),4)}; + $('jobInfo').innerHTML='

    '+m.name+'

    '+esc(T(m.brief))+'
    '+(r.seen&&need?'
    '+esc(T('Worth bringing:'))+' '+esc(need)+'
    ':'')+'
    '+esc(r.n?T('Done before: a repeat pays half.'):T('Pays up to {n}',{n:Math.round(m.pay*1.2)+' ◈'}))+'
    '; + $('bTake').disabled=!unlocked(EWMaps.indexOf(m));$('bTake').textContent=vanNeeded()?T('Take this job'):T('Go')} +$('bTake').onclick=function(){selJob=pick;if(vanNeeded()){closeSub();toast(T('Job taken. Load the van to set off.'),4)}else enter(jobBy(selJob))}; function drawShop(){$('shopCoins').textContent=save.coins+' ◈';var h=$('gearList');h.innerHTML='';GEAR.forEach(function(g){if(!g.price)return;var d=document.createElement('div');d.className='gi';var own=save.gear[g.id],locked=g.need&&!save.gear[g.need]; d.innerHTML=''+esc(T(g.name))+''+esc(T(g.desc))+(locked?' '+esc(T('Needs: {g}.',{g:T(GEARBY[g.need].name)})):'')+''; if(own){var s=document.createElement('span');s.className='own';s.textContent=T('Owned');d.appendChild(s)}else{var b=document.createElement('button');b.className='btn';b.setAttribute('data-noi18n','');b.textContent=g.price+' ◈';b.disabled=locked||save.coins=0,b=document.createElement('button');b.className='gi'+(on?' sel':'');b.setAttribute('aria-pressed',on?'true':'false'); @@ -623,19 +535,19 @@ function seg(id,key,after){var el=$(id);function paint(){[].forEach.call(el.chil [].forEach.call(el.children,function(b){b.onclick=function(){save.set[key]=isNaN(+b.dataset.v)?b.dataset.v:+b.dataset.v;persist();paint();if(after)after()}});paint()} $('sSens').value=save.set.sens;$('sVol').value=save.set.vol; $('sSens').oninput=function(){save.set.sens=+this.value;persist()};$('sVol').oninput=function(){save.set.vol=+this.value;persist();if(master)master.gain.value=save.set.vol}; -seg('sQ','q',resize);seg('sInv','inv'); +seg('sQ','q',function(){resize();fitShadow()});seg('sInv','inv'); // ---------------------------------------------------------------- keyboard and mouse addEventListener('keydown',function(e){ if(e.target&&e.target.tagName==='INPUT')return;keys[e.code]=true; if(state==='play'){ if(e.code==='Space'){inp.jump=true;e.preventDefault()} - else if(e.code==='Tab'||e.code==='KeyJ'){e.preventDefault();openSub('journal')} + else if(e.code==='Tab'||e.code==='KeyJ'){e.preventDefault();if(!def.depot&&!firstJob())openSub('journal')} else if(e.code==='KeyF')scan(); else if(e.code==='KeyE'){if(!e.repeat){inp.act=true;inp.tap=true}} else if(e.code==='KeyR'){rot=(rot+1)%4;sfx('tick',0.5)} else if(e.code==='KeyP')pause(); - else if(/^Digit[1-9]$/.test(e.code))selectTool(+e.code.slice(5)-1); + else if(/^Digit[1-9]$/.test(e.code))selectTool(+e.code.slice(5)-1,true); }else if(e.code==='Escape'||e.code==='Tab'||e.code==='KeyJ'){ e.preventDefault();if(!$('pause').hidden){if(e.code==='Escape')resume()}else if($('menu').hidden&&$('result').hidden)closeSub(); } @@ -647,7 +559,7 @@ canvas.addEventListener('mousedown',function(e){if(touchUI||state!=='play')retur if(e.button===0){useHeld=true;useTool(false)}else if(e.button===2){altHeld=true;useTool(true)}}); addEventListener('mouseup',function(e){if(e.button===0)useHeld=false;else if(e.button===2)altHeld=false}); canvas.addEventListener('contextmenu',function(e){e.preventDefault()}); -canvas.addEventListener('wheel',function(e){if(state!=='play'||!bar.length)return;e.preventDefault();selectTool((cur+(e.deltaY>0?1:-1)+bar.length)%bar.length)},{passive:false}); +canvas.addEventListener('wheel',function(e){if(state!=='play'||bar.length<2)return;e.preventDefault();selectTool((cur+(e.deltaY>0?1:-1)+bar.length)%bar.length,true)},{passive:false}); function readKeys(){if(touchUI)return;inp.mz=(keys.KeyW||keys.ArrowUp?1:0)-(keys.KeyS||keys.ArrowDown?1:0);inp.mx=(keys.KeyD||keys.ArrowRight?1:0)-(keys.KeyA||keys.ArrowLeft?1:0); inp.sprint=!!(keys.ShiftLeft||keys.ShiftRight);inp.crouch=!!(keys.KeyC||keys.ControlLeft)} @@ -671,7 +583,6 @@ function readKeys(){if(touchUI)return;inp.mz=(keys.KeyW||keys.ArrowUp?1:0)-(keys btn('tJump',function(){inp.jump=true}); btn('tAct',function(){inp.act=true;inp.tap=true},function(){inp.act=false}); btn('tRot',function(){rot=(rot+1)%4;sfx('tick',0.5)}); - var cr=$('tCrouch');cr.addEventListener('touchstart',function(e){e.preventDefault();inp.crouch=!inp.crouch;cr.classList.toggle('on',inp.crouch)},{passive:false}); })(); // ---------------------------------------------------------------- the loop @@ -682,14 +593,16 @@ function frame(now){ if(document.hidden||!world)return; if(state==='play'){ readKeys();var mn=Math.ceil(dt/0.04),mk;for(mk=0;mk=STEP&&n<8){world.step(STEP);acc-=STEP;n++}if(n){updateWaterMesh();simMs+=(performance.now()-t0-simMs)*0.1}if(acc>STEP)acc=0; - var hid=tool();if(useHeld&&(hid==='rake'||hid==='shovel'||hid==='squeegee'))useTool(false);if(altHeld&&hid==='rake')useTool(true); - updateThings(dt,now/1000);updateGhost();animView(dt);updateHud(dt); - if(!def.depot&&state==='play'&&world.isDone()){endT+=dt;if(endT>2.5)finishJob()}else endT=0; + var hid=tool();if(useHeld&&(hid==='rake'||hid==='shovel'||hid==='squeegee'))useTool(false); + updateThings(dt,now/1000);updateFx(dt,now/1000);updateGhost();animView(dt);updateHud(dt); + if(!def.depot&&state==='play'&&world.isDone()){endT+=dt;if(endT>2.2)finishJob()}else endT=0; } audioTick(); if(state==='menu')return; - if(state==='play'&&!autoLow&&save.set.q==='auto'){fpsT+=dt;fpsN++;if(fpsT>=3){var fps=fpsN/fpsT;fpsT=0;fpsN=0;slowN=fps<34?slowN+1:0;if(slowN>=3){autoLow=true;resize()}}} + // On Auto, when frames stay poor for nine seconds: first High drops to Low, then Low drops the mirror pass. It never steps back up. + if(state==='play'&&save.set.q==='auto'&&!mirrorOff){fpsT+=dt;fpsN++;if(fpsT>=3){var fps=fpsN/fpsT;fpsT=0;fpsN=0;slowN=fps<(quality()==='high'?34:27)?slowN+1:0;if(slowN>=3){slowN=0;if(quality()==='high'){autoLow=true;resize();fitShadow()}else mirrorOff=true}}} U.uT.value=now/1000;U.uCam.value.copy(camera.position);skyDome.position.copy(camera.position);renderReflection(); renderer.render(scene,camera); } @@ -697,5 +610,5 @@ show('menu');requestAnimationFrame(frame); // for tests and tuning from the console window.__ew={ff:function(sec){for(var k=0;k @@ -186,52 +181,44 @@