diff --git a/README.md b/README.md index ab357434..169eff2d 100644 --- a/README.md +++ b/README.md @@ -66,7 +66,7 @@ Personal site hosted with GitHub Pages at **https://ascoding11.github.io**, the - `e63334287a3deaa3/patchwork-tower/`: Patchwork Tower (Back Room), a one-screen fix-it arcade game in pixel art for one player (one file, one canvas, Web Audio, no libraries, no Firebase except stats.js). It took the place of Hivefix; `e63334287a3deaa3/hivefix/index.html` is now only a redirect to it, so old links and bookmarks still work (`m/thumbs/hivefix.jpg` stays for the old What's new entry). Rivet, a repair bot with a wrench, hops between the windows of a brick tower at night (5 across, 4 down) and fixes each broken one until it glows; cracked windows take one fix, dark ones two, and fixing roots the bot to the spot. A gargoyle walks along the roof, stops over a column (more often than not the bot's), winds up (eyes red, a red arrow under the roof ledge on every column about to be hit) and kicks a brick straight down it. Clearing every window ends the floor (500 plus 10 for each second left of 60) and the next one starts with a new layout. **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)`, `step(g, 1/120)`, `press(g, k)` for a tap and `hold(g, k, on)` while a key or button is down, with k one of up, down, left, right, fix; what should be heard goes into `g.ev` as words the page plays). `g.win[r][c]` is 0 fixed / 1 cracked / 2 dark; `g.blockV[r][c]` is a planter under the sill of (r, c), which blocks climbing between rows r and r+1; `g.blockH[r][c]` is an open shutter between (r, c) and (r, c+1), which blocks stepping sideways. **Tuning** is the constants at the top of the rules: a hop takes 0.12 s (`HOP`), a fix 0.26 s (`FIX`; 0.08 s with cocoa), a press made during a hop or fix is remembered for 0.3 s (`BUF`), a held direction or FIX repeats after 0.22 s (`REPEAT`), the wind-up is 0.4 s (`TELE`) plus 0.3 s on floor 1 shrinking to nothing by floor 4 (`TELE_EARLY`), 3 lives, a hit freezes the world for 1 s and restarts the bot at the door with 2 s of blinking. Per floor: 7 + 2 × floor windows broken (all 20 from floor 7), the chance one is dark is 0.15 + 0.1 × floor up to 0.75, one more planter or shutter each floor up to four (each on its own edge, redrawn until every window can be reached), the gargoyle walks at 55 + 9 × floor pixels a second, bricks fall at 65 + 11 × floor, and its rest between kicks is 1.5 − 0.13 × floor seconds, never under 0.35; the speeds stop rising at floor 12 (`TOP_LEVEL`). From floor 2, bats cross a row (an arrow blinks at that edge of the row for 0.8 s first, `BAT_WARN`); from floor 3 a kick sometimes (35%) sends a second brick down a neighbouring column 0.18 s later, chosen at the start of the wind-up so its arrow shows too. Cocoa appears on a sill now and then for 7 s: 6 s safe from everything, the first 4 with one-tap repairs, +300. The hit boxes are narrower than the sprites (9 pixels either side for bricks and bats). **Drawing**: the game is a 240 × 320 picture. `layout()` shows it at a whole number of device pixels per game pixel (the canvas is sized in device pixels and scaled back by 1/devicePixelRatio, its corner snapped to a device pixel), so pixels stay square and sharp on any screen; never size the canvas with CSS percentages or `vh`. The sky, skyline and brickwork are drawn once (`back`), the windows, planters and shutters are redrawn only when one changes (`g.winDirty`), and words use a 5 × 5 pixel alphabet drawn in code (`FONT`, capitals, digits and `+ - : ! .` only), not a web font. The loop runs the rules in fixed steps of 1/120 s and draws between steps, so it plays at the same speed on 60, 120 and 144 Hz screens. The game pauses when the tab is hidden or the window loses focus. **Saved in the browser only**: `patchwork-best`, `patchwork-mute` (in try/catch), keys under `keybinds:patchwork-tower`. Stats hook: `max('score', score)` and `max('floor', floor reached)` when a floor is cleared and at game over (the Leaderboards show best score). Controls: arrows or WASD hop (hold to keep hopping), Space, Z or X fix (hold to keep fixing), P, Enter or Esc pause, M sound, all rebindable under KEYS. On touch screens (`body.touch`): a d-pad (slide a thumb between arrows) and a round FIX button under the screen, or either side of it when the phone is sideways. How to play sits beside the screen when there is room, otherwise behind the ? button. A test hook (`window.__pt`) exists only when `navigator.webdriver` is set. It has Spanish: its words are in `patchwork-tower/es.js` (lang.js), with a Language switch in How to play; the canvas words are chosen to need no accents, since the 5×5 pixel font has none. **The Wardrobe** (captains only for now, like the other games' hidden cosmetics): 29 looks for Rivet in `patchwork-tower/wardrobe.js`, listed in `cosmetics.js` under `GAMES['patchwork-tower']` (15 paint jobs, 7 hats, 3 face pieces and 4 hop trails: sports kits, tin and chrome robots, pirates, suits and more). The page fetches `wardrobe.js` and `../cosmetics.js` only when `wardrobeOn()` is true (`PATCHWORK_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 the bot is drawn exactly as before. Looks only: a paint job recolours the bot's own rectangles (cocoa still turns it gold, the blinking after a hit is unchanged), every paint stands out from the bricks at least 3.5 times (`MIN_CR`; factory teal is 4.1) and none is brick-orange or bat-lilac, hats sit on the head (some in place of the antenna), face pieces go on the visor, and hop trails are drawn under the bricks, bats and bot and fade within half a second. Opening it pauses a game in progress. What is worn is saved in this browser as `patchwork-look` (`{p, h, f, t}`, item numbers, 0 for none); nothing is sent anywhere. The words are in `es.js`. - `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 that walks and aims perfectly fills its first sack in about 9 game-seconds, buys Quick hands (25) after its second sack, the rake (60) at about 45 s and clears the yard in about 150 s; a person takes longer. The "hold to gather" line stays until the sack is half full. **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/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 short card at the start says what the game is and to pick up the leaves at your feet (`#intro`, gone after the first grab, and never shown with a notification). **Grabbing:** each click or tap picks up the leaves in a small circle where you look (`GRAB_R` in `game.js`: about 0.2 m across at first, so one to a few leaves; the circle is drawn over the leaves), at most one grab every 0.18 s. Bigger handfuls (the upgrade id `hands`, so older levels carry over) widens the circle in four steps; Steady hands (`hold`, offered once the rake is owned) keeps grabbing while the button is held. **Rake:** when bought it only pulls; Rake push (`rakePush`, 60) turns it round, and R or the Push/Pull button switches (`state.rakeMode`). Older saves keep what they had: a save with acorns earned before this change gets Steady hands, and one that owns the rake gets Rake push, so nobody loses holding to gather or pushing. A scripted player clicking 2.5 times a second empties its first sack in about 35 to 50 game-seconds, buys the rake (50) at about 2 to 3 minutes and clears the yard in 5 to 6.5 minutes; it clicks wastefully, so a careful person may be faster and a new one slower. **Captains** (`../captains.js`, `BackRoomCaptains.may(false, 'gardens')`, or `?gardens=1` on localhost or in an automated browser) find every gate open for that visit, so any garden can be tested at once; nothing is saved, no acorns or upgrades are given, and the gardens still count as locked in the save. **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` (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`, rewritten 26 Nov 2026 because the first version looked wrong: a checkerboard shimmer and a slow slosh):** the shallow-water equations on a grid of 0.5 m cells. Each cell has a ground height `g`, a barrier height `bar` laid on top and a depth `d` (kept in 64-bit numbers: with 32-bit ones a slow seep into a deep cell rounded away and volume drifted); each edge between two cells has a water speed (`u` across a cell's east edge, `v` across its south edge, m/s), so the water carries momentum: a current keeps going round a corner, piles up against a wall and swirls behind it. Every step (1/30 s, fixed): the speeds are carried along by the flow itself (semi-Lagrangian advection), speed up downhill on the water surface (`GRAV`), and are slowed by Manning friction (`mann`, 0.018), a drag on thin films (`film`) so a wet floor creeps rather than races, and a gentle linear drag (`drag`, 0.2 per second) so a pool settles instead of sloshing for minutes; then each edge carries speed × the depth on its upstream side (`fx`, `fy`), no cell may give more than it holds (flows out of a cell are scaled down together, and so are their speeds), 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. `push(x, z, vx, vz, r, f, dt)` shoves the water near a point along a velocity without adding or removing any (the player wading: a bow wave ahead and a wake behind). `vel(i, out)` gives a cell's current for drawing and for debris. 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). One step with every block awake costs a few ms for the biggest job (68 × 48) on a desktop. `drag` and `film` were tuned so every job drains at least as fast as with the old water (node bot times, old to new: Marlow Row 152 to 157 s, Pell Street 182 to 181, Tanners Field 343 to 304, Fenny Underpass 246 to 255, Wharf Cellar 221 to 213, Mill Lane 411 to 346); raising them makes the long jobs drag on. **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 × World.DRAINX × (0.03 + 0.97 × clear^1.25)`, and it takes that from its own cell and, when that runs short, from the cells within about a metre (`catchment`), so a cleared drain visibly pulls the level down. `World.DRAINX` (2.5) and `World.PUMPX` (2, on `pumpRate`) were added on 26 Nov 2026 when the owner found draining too slow; node bot times after that change: Marlow Row 72 s, Pell Street 109, Tanners Field 215, Fenny Underpass 153, Wharf Cellar 173, Mill Lane 310. 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.9 m (raised from 0.64 in Nov 2026 so a cut through Tanners Field's bank goes lower than a one-dig trench in the field); 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 dripping joint on that pipe for the wrench, a second smaller drain by the side path, and a hollow in the lawn with a lip round it (in `ground`) that keeps a puddle only the bucket can empty; 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, marked out by two lines of orange survey pegs with string (`deco` kind `pegs`); the hollow falls towards that line; the ditch slopes south along the hedge and only its far end (`sinkArea`) takes water away, so water can be seen running into it and along it, and the ditch is `noJob`; a choked culvert, drawn with a concrete pipe through the bank (`drain` option `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, and given more to do the same day after they found it too basic):** Play puts a new player straight into Marlow Row holding the rake and nothing else. `GUIDES.yard` gives one short line at a time at the bottom of the screen and each goes when it has been done: move, find the drain, rake it, follow the pipe to the tap and shut it, tighten the dripping joint (the wrench joins the bar, key 2), rake the second drain, empty the lawn puddle with the bucket (it joins the bar, key 3), keep the drains clear until it is dry. A step's `give` adds its tool to the bar. `GUIDES.field` does the same for Tanners Field (shut the standpipe, follow the pegs, dig through the bank, carry the trench back one dig deep, keep it running). A guide runs until that job has a star, and a job cannot finish while its guide is still running (the last step is always "until it is dry"). 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. **Captains** (`BackRoomCaptains.may` from `../captains.js`, loaded in the page's ``; on localhost and in test browsers `?floodcap=1` stands in): Play goes straight to the depot, every job on the board is open, and in a job the bar holds every tool that job's `needs` lists as well as their own (with the usual sandbags, pump and generator). Nothing of it is saved: their save keeps only the stars and pay they earn. Ordinary players are unchanged. **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 a few centimetres wide at the edge (measured with screen-space derivatives of the depth, so it stays thin on a gentle slope and only shows where the water is under about 9 cm). Between two water steps the vertices are blended from the last step to this one (`aPrev`, `uLerp`), so the surface moves at the screen's frame rate, not 30 times a second. The surface slope of the simulation (`aSlope`) tilts the lighting, so a wake or a bow wave shows as a darker or brighter band. Up to four running drains (`uDr`) each get a whirlpool: a dip in the surface, the pattern twisted round the drain, a dark eye and thin spiral streaks. The ground under shallow water is tinted and gets moving caustics (High only). **Ripples** are a separate wave-equation height field on the graphics card (`RIP`: two half-float pictures swapped each step, 0.07 m texels on High at 60 steps a second, 0.12 m at 30 on Low, damped, and faded out where the flood is under about 2 cm, from a small picture of the depths, `tSim`, updated each water step). `rip(x, z, r, a)` drops a ring-shaped bump in (up to 16 a frame): the legs when wading, and everything that calls `ring()` (splashes and the like), which uses it in place of flat ring sprites. The water shader reads the ripple slope to bend the reflection and the light, with pale crests where it is steep. Without WebGL2 and half-float render targets ripples are off (`RIP.ok`) and `ring()` falls back to sprites. `__ew.U.uRipDbg.value = 1` shows the ripple heights in false colour, for tuning. 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`). The scene is drawn once more upside down into a picture (`renderReflection`) so the water mirrors the buildings and sky: half the screen's resolution every frame on High, a third of it (at least 256 × 160) every other frame on Low; the sun's disc is left out of that pass (`uNoSun`) because a mirrored sun clipped to white blotches, and the water adds its own sharp sun glint instead. On Low the water also skips its two finest pattern layers, the silt layer and two of the four ripple reads (`uHi`). 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". diff --git a/e63334287a3deaa3/news/ngcoding10-leaf-tune.json b/e63334287a3deaa3/news/ngcoding10-leaf-tune.json new file mode 100644 index 00000000..1aa62577 --- /dev/null +++ b/e63334287a3deaa3/news/ngcoding10-leaf-tune.json @@ -0,0 +1,19 @@ +{ + "kind": "feature", + "title": "Leaf Sweep: one handful at a time", + "tags": [ + "Leaf Sweep" + ], + "items": [ + "Leaf Sweep now starts with a short note on what to do, and you pick up leaves one handful at a time: each click or tap grabs what is in a small circle.", + "Bigger handfuls widens that circle, and Steady hands later lets you hold to keep grabbing.", + "The rake pulls at first; Rake push lets it push leaves away too. If you already had the rake, you keep pushing." + ], + "es": { + "Leaf Sweep: one handful at a time": "Leaf Sweep: un puñado a la vez", + "Leaf Sweep": "Leaf Sweep", + "Leaf Sweep now starts with a short note on what to do, and you pick up leaves one handful at a time: each click or tap grabs what is in a small circle.": "Leaf Sweep ahora empieza con una nota breve sobre qué hacer, y recoges las hojas un puñado a la vez: cada clic o toque agarra lo que hay en un círculo pequeño.", + "Bigger handfuls widens that circle, and Steady hands later lets you hold to keep grabbing.": "Puñados más grandes agranda ese círculo, y más adelante Manos firmes te deja mantener pulsado para seguir agarrando.", + "The rake pulls at first; Rake push lets it push leaves away too. If you already had the rake, you keep pushing.": "Al principio el rastrillo solo tira; el empuje del rastrillo te deja también empujar las hojas. Si ya tenías el rastrillo, sigues pudiendo empujar." + } +} diff --git a/e63334287a3deaa3/windrow/es.js b/e63334287a3deaa3/windrow/es.js index c0fa3c56..b0e87bd0 100644 --- a/e63334287a3deaa3/windrow/es.js +++ b/e63334287a3deaa3/windrow/es.js @@ -83,5 +83,22 @@ if (window.BackRoomLang) BackRoomLang.add({ 'The gate is open: the next garden is waiting': 'El portón está abierto: el siguiente jardín te espera', 'Leaves that reach a yellow grate are paid at once': 'Las hojas que llegan a una rejilla amarilla se pagan al instante', 'Clear every leaf in the yard and this gate opens': 'Limpia todas las hojas de este jardín y el portón se abre', - '{m} to walk, mouse to look, hold the left button to work, {j} to jump. {a} to switch tools, {e} at a bin or gate, {t} for the shed and map, {f} for the leaf finder.': '{m} para caminar, mouse para mirar, mantén el botón izquierdo para trabajar y {j} para saltar. {a} para cambiar de herramienta, {e} en una compostera o portón, {t} para el cobertizo y el mapa y {f} para el buscador de hojas.' + '{m} to walk, mouse to look, hold the left button to work, {j} to jump. {a} to switch tools, {e} at a bin or gate, {t} for the shed and map, {f} for the leaf finder.': '{m} para caminar, mouse para mirar, mantén el botón izquierdo para trabajar y {j} para saltar. {a} para cambiar de herramienta, {e} en una compostera o portón, {t} para el cobertizo y el mapa y {f} para el buscador de hojas.', + // grabbing one handful at a time, rake push, steady hands, the opening card, captains + 'Grab': 'Agarrar', 'Blow': 'Soplar', 'Push': 'Empujar', 'Pull': 'Tirar', + 'The old gardens are buried in leaves. Clear every last one.': 'Los viejos jardines están enterrados en hojas. Limpia hasta la última.', + 'Start here: click to pick up the leaves at your feet.': 'Empieza aquí: haz clic para recoger las hojas a tus pies.', + 'Start here: tap Grab to pick up the leaves at your feet.': 'Empieza aquí: toca Agarrar para recoger las hojas a tus pies.', + 'Click to pick up the leaves in the circle': 'Haz clic para recoger las hojas del círculo', 'Tap Grab to pick up the leaves in the circle': 'Toca Agarrar para recoger las hojas del círculo', + 'Bigger handfuls': 'Puñados más grandes', 'Each grab picks up more leaves': 'Cada vez que agarras recoges más hojas', + 'Rake push': 'Empujar con el rastrillo', 'Turn the rake round to push leaves away as well as pull them': 'Da vuelta el rastrillo para empujar las hojas además de tirar de ellas', + 'Steady hands': 'Manos firmes', 'Hold to keep grabbing instead of one grab a click': 'Mantén pulsado para seguir agarrando en vez de un puñado por clic', + 'Buy rake push in the shed to push leaves away': 'Compra el empuje del rastrillo en el cobertizo para empujar las hojas', + 'Rake: push': 'Rastrillo: empujar', 'Rake: pull': 'Rastrillo: tirar', 'Rake pushes': 'El rastrillo empuja', 'Rake pulls': 'El rastrillo tira', + 'Rake push: tap Push or Pull to switch': 'Empuje del rastrillo: toca Empujar o Tirar para cambiar', + 'Rake push: press {k} to switch between pull and push': 'Empuje del rastrillo: pulsa {k} para cambiar entre tirar y empujar', + 'Steady hands: hold Grab to keep picking up': 'Manos firmes: mantén Agarrar para seguir recogiendo', + 'Steady hands: hold the mouse button to keep picking up': 'Manos firmes: mantén el botón del mouse para seguir recogiendo', + 'Rake: pull or push': 'Rastrillo: tirar o empujar', 'After you buy rake push': 'Cuando compres el empuje del rastrillo', + 'Captain: every garden is open for testing': 'Capitán: todos los jardines están abiertos para probar' }); diff --git a/e63334287a3deaa3/windrow/index.html b/e63334287a3deaa3/windrow/index.html index a0310331..d3c39bc4 100644 --- a/e63334287a3deaa3/windrow/index.html +++ b/e63334287a3deaa3/windrow/index.html @@ -88,6 +88,12 @@ #tJump{right:calc(126px + var(--sr));bottom:calc(22px + var(--sb));width:62px;height:62px} #tSprint{right:calc(122px + var(--sr));bottom:calc(100px + var(--sb));width:54px;height:54px;font-size:11px} #tKneel{right:calc(30px + var(--sr));bottom:calc(134px + var(--sb));width:54px;height:54px;font-size:11px} +#tMode{right:calc(30px + var(--sr));bottom:calc(200px + var(--sb));width:54px;height:54px;font-size:11px;background:rgba(63,107,82,.75)} +#intro{position:absolute;left:50%;top:30%;transform:translateX(-50%);width:min(88vw,460px);background:rgba(246,236,212,.94);color:var(--ink);border:1px solid var(--line);border-radius:16px;padding:14px 18px;text-align:center;box-shadow:0 8px 26px rgba(0,0,0,.25);animation:hintIn .5s} +#intro b{display:block;font-family:var(--f-d);font-size:20px;line-height:1.25} +#intro span{display:block;margin-top:6px;font-size:16px;color:var(--ink-2)} +#rakeMode{position:absolute;left:50%;bottom:calc(70px + var(--sb));transform:translateX(-50%);font-size:13px;color:#fff;text-shadow:0 1px 3px rgba(0,0,0,.7)} +#rakeMode kbd{font:inherit;background:var(--gold);color:var(--ink);border-radius:5px;padding:0 6px;margin-right:5px;text-shadow:none} #tAct{left:50%;bottom:calc(84px + var(--sb));transform:translateX(-50%);border-radius:14px;width:auto;height:48px;padding:0 18px;font-size:15px;background:rgba(224,181,58,.95);color:var(--ink);border-color:#fff;white-space:nowrap} #tTop{position:absolute;right:calc(10px + var(--sr));top:calc(10px + var(--st));display:flex;gap:8px} #tTop .tb{position:static;width:46px;height:46px;border-radius:12px;font-size:11px} @@ -99,8 +105,9 @@ body.touch #hTools{bottom:calc(172px + var(--sb))} body.touch #hArea{top:calc(96px + var(--st))} body.touch #toasts{top:34%} - body.touch #hint,body.touch #hPrompt{bottom:calc(238px + var(--sb))} - body.touch #tAct{bottom:calc(234px + var(--sb))} + body.touch #hint,body.touch #hPrompt{bottom:calc(270px + var(--sb))} + #intro{top:calc(160px + var(--st))} + body.touch #tAct{bottom:calc(266px + var(--sb))} } @media (orientation:landscape) and (max-height:480px){ #hArea{padding:4px 12px 5px;min-width:170px}#hArea b{font-size:15px} @@ -109,6 +116,8 @@ body.touch #tJump{right:calc(110px + var(--sr));bottom:calc(12px + var(--sb));width:56px;height:56px} body.touch #tSprint{right:calc(108px + var(--sr));bottom:calc(80px + var(--sb));width:48px;height:48px} body.touch #tKneel{right:calc(26px + var(--sr));bottom:calc(106px + var(--sb));width:48px;height:48px} + body.touch #tMode{right:calc(26px + var(--sr));bottom:calc(160px + var(--sb));width:48px;height:48px} + #intro{top:36%;padding:10px 14px}#intro b{font-size:17px}#intro span{font-size:14px} body.touch #hTools{bottom:calc(8px + var(--sb))} body.touch .slot{width:52px;height:44px;font-size:10px}body.touch .slot svg{width:20px;height:20px} #hPrompt,#hint{bottom:calc(64px + var(--sb));font-size:15px;padding:6px 14px;max-width:46vw} @@ -164,6 +173,7 @@ @media (max-height:480px){.card{padding:12px 16px}#title h1{font-size:40px}.stack{margin-top:8px;flex-direction:row;flex-wrap:wrap;justify-content:center}.tag{font-size:15px;margin:4px 0}#jSide{max-height:56vh}#jBody{grid-template-columns:minmax(0,1fr) minmax(0,1.2fr)}} @media (prefers-reduced-motion:reduce){.toast,#acN.pop{animation:none}} + @@ -181,6 +191,8 @@
+ +
@@ -194,6 +206,7 @@ +
diff --git a/e63334287a3deaa3/windrow/js/audio.js b/e63334287a3deaa3/windrow/js/audio.js index 57ed9aea..acca1d66 100644 --- a/e63334287a3deaa3/windrow/js/audio.js +++ b/e63334287a3deaa3/windrow/js/audio.js @@ -54,6 +54,8 @@ A.gate = function () { tone('sawtooth', 90, 140, 0.7, 0.05); burst(500, 3, 0.7, 0.08); }; A.step = function (wood) { if (wood) { tone('sine', 150, 90, 0.07, 0.07); burst(900, 1, 0.04, 0.04); } else burst(260 + Math.random() * 120, 0.9, 0.07, 0.07); }; A.jump = function () { burst(500, 0.6, 0.12, 0.05); }; + A.grab = function (v) { burst(3600 + Math.random() * 1800, 1.6, 0.09 + 0.08 * (v || 0), 0.1 + 0.08 * (v || 0)); tone('sine', 900 + Math.random() * 200, 600, 0.05, 0.035); }; + A.miss = function () { burst(2400, 2, 0.05, 0.04); }; A.thud = function (v) { tone('sine', 170, 80, 0.12, 0.06 + 0.1 * (v || 0)); burst(1800, 0.7, 0.14, 0.05 + 0.08 * (v || 0)); }; A.burst = function (v) { burst(4200, 0.5, 0.5, 0.12 + 0.2 * (v || 0)); burst(1500, 0.6, 0.3, 0.1 + 0.12 * (v || 0)); tone('sine', 140, 60, 0.18, 0.12); }; })(); diff --git a/e63334287a3deaa3/windrow/js/game.js b/e63334287a3deaa3/windrow/js/game.js index 45abf7a3..67b84582 100644 --- a/e63334287a3deaa3/windrow/js/game.js +++ b/e63334287a3deaa3/windrow/js/game.js @@ -12,8 +12,10 @@ /* ---------- upgrades (the shed) ---------- */ var UP = WR.UPGRADES = [ { id: 'sack', name: 'Bigger sack', text: 'Carry more leaves before a trip to the bin', costs: [40, 110, 260, 600, 1300] }, - { id: 'hands', name: 'Quick hands', text: 'Gather faster and reach wider', costs: [25, 80, 200, 500] }, - { id: 'rake', name: 'Rake', text: 'Drags a whole row of leaves toward you with every stroke', costs: [60] }, + { id: 'hands', name: 'Bigger handfuls', text: 'Each grab picks up more leaves', costs: [20, 60, 160, 420] }, + { id: 'rake', name: 'Rake', text: 'Drags a whole row of leaves toward you with every stroke', costs: [50] }, + { id: 'rakePush', name: 'Rake push', text: 'Turn the rake round to push leaves away as well as pull them', costs: [60], needs: 'rake' }, + { id: 'hold', name: 'Steady hands', text: 'Hold to keep grabbing instead of one grab a click', costs: [120], needs: 'rake' }, { id: 'rakeW', name: 'Wider rake', text: 'A broader head moves more leaves a stroke', costs: [120, 320, 800], needs: 'rake' }, { id: 'blower', name: 'Leaf blower', text: 'Pushes leaves away in a cone of wind', costs: [350] }, { id: 'power', name: 'Stronger motor', text: 'The blower pushes harder', costs: [300, 700, 1500], needs: 'blower' }, @@ -21,22 +23,27 @@ { id: 'value', name: 'Rich compost', text: 'Every leaf pays 15% more', costs: [90, 220, 500, 1100, 2400] }, { id: 'shoes', name: 'Light boots', text: 'Walk 10% faster', costs: [70, 190, 450] } ]; - var SACK = [30, 55, 90, 140, 210, 320], HAND_RATE = [4, 9, 17, 27, 40], HAND_REACH = [0.95, 1.1, 1.25, 1.45, 1.7]; + var SACK = [30, 55, 90, 140, 210, 320], GRAB_R = [0.2, 0.36, 0.52, 0.72, 0.95], GRAB_GAP = 0.18, HOLD_GAP = 0.32; // radius of one grab (m) per level; shortest time between grabs; between held grabs var RAKE_W = [1.0, 1.4, 1.9, 2.5], BLOW_P = [20, 28, 38, 50], BLOW_R = [4.5, 5.8, 7.2, 9], BLOW_H = [0.3, 0.36, 0.42, 0.5]; WR.sackCap = function (s) { return SACK[s.up.sack]; }; WR.rakeWidth = function (s) { return RAKE_W[s.up.rakeW]; }; var TOOL_NAMES = ['Hands', 'Rake', 'Blower']; /* ---------- saved state ---------- */ function fresh(set) { - return { v: 1, acorns: 0, earned: 0, up: { sack: 0, hands: 0, rake: 0, rakeW: 0, blower: 0, power: 0, nozzle: 0, value: 0, shoes: 0 }, + return { v: 1, acorns: 0, earned: 0, up: { sack: 0, hands: 0, rake: 0, rakePush: 0, hold: 0, rakeW: 0, blower: 0, power: 0, nozzle: 0, value: 0, shoes: 0 }, unlocked: [0, 0, 0, 0, 0, 1], done: [0, 0, 0, 0, 0, 0], rewards: {}, bagUnits: [0, 0, 0, 0, 0, 0], bagFill: 0, gone: [0, 0, 0, 0, 0, 0], tool: 0, tut: 0, seen: {}, pos: null, set: set || { sens: 1, vol: 0.7, q: null, inv: false, picked: false }, leaves: null, leafMul: 0, secs: 0, binFill: 0 }; } var state = fresh(); - try { var raw = JSON.parse(localStorage.getItem(KEY) || 'null'); if (raw && raw.v === 1) { var f = fresh(); for (var k in f) if (raw[k] != null) state[k] = raw[k]; for (k in f.up) if (state.up[k] == null) state.up[k] = 0; for (k in f.set) if (state.set[k] == null) state.set[k] = f.set[k]; } } catch (e) {} + try { var raw = JSON.parse(localStorage.getItem(KEY) || 'null'); if (raw && raw.v === 1) { var f = fresh(); for (var k in f) if (raw[k] != null) state[k] = raw[k]; + // nobody loses an ability: a save from before grabbing one handful at a time kept gathering by holding, and a rake bought before push was split off could push + if (raw.up && raw.up.hold == null && raw.earned > 0) state.up.hold = 1; + if (raw.up && raw.up.rakePush == null && raw.up.rake) state.up.rakePush = 1; + for (k in f.up) if (state.up[k] == null) state.up[k] = 0; for (k in f.set) if (state.set[k] == null) state.set[k] = f.set[k]; } } catch (e) {} // a save from before the Front Yard existed has five gardens: it keeps them as they were and gets the yard, open, as a sixth ['unlocked', 'done', 'bagUnits', 'gone'].forEach(function (key) { if (!Array.isArray(state[key])) state[key] = fresh()[key]; while (state[key].length < A.length) state[key].push(key === 'unlocked' && state[key].length === WR.YARD ? 1 : 0); }); - if (state.unlocked[0] && !state.seen.grab) state.seen = { grab: 1, bin: 1, chute: 1, shop: 1 }; + if (state.unlocked[0] && !state.seen.grab) state.seen = { grab: 1, bin: 1, chute: 1, shop: 1, intro: 1 }; + if (state.earned > 0) state.seen.intro = 1; var touchDev = window.matchMedia && matchMedia('(pointer:coarse)').matches, touchUI = false; if (!state.set.q) state.set.q = touchDev ? 'low' : 'medium'; var dirty = false, saveT = 0; @@ -54,10 +61,23 @@ // colours are authored as screen colours and lit in linear light; bright things roll off instead of clipping renderer.outputEncoding = THREE.sRGBEncoding; renderer.toneMapping = THREE.ACESFilmicToneMapping; renderer.toneMappingExposure = 1.0; var scene = new THREE.Scene(), camera = new THREE.PerspectiveCamera(72, 1, 0.08, 600); camera.rotation.order = 'YXZ'; + /* Captains (../captains.js) can walk into every garden to test it: all gates open for them, for this visit only. + Nothing is saved and nothing else changes (no acorns, no upgrades, gardens still count as locked in the save). + The same happens with ?gardens=1 on localhost or in an automated browser (captains.js's test switch). */ + var capOpen = false; + function isOpen(i) { return !!state.unlocked[i] || capOpen; } + function openView() { return { unlocked: A.map(function (a, i) { return isOpen(i) ? 1 : 0; }) }; } WR.buildGrid(state.unlocked); var world = WR.buildWorld(scene), vm = WR.buildViewModels(scene, state), fx = new WR.Fx(scene, 90), leaves = null; world.sun.shadow.autoUpdate = false; world.gates.forEach(function (G) { if (state.unlocked[G.def.area]) { G.open = G.target = 1; } }); + function captainCheck() { + var C = window.BackRoomCaptains, on = !!(C && C.may(false, 'gardens', 'windrow:gardens')); + if (!on || capOpen) return; capOpen = true; + A.forEach(function (a, i) { if (!state.unlocked[i]) WR.openGate(i); }); world.gates.forEach(function (G) { G.target = 1; }); + world.refreshSigns(openView()); world.sun.shadow.needsUpdate = true; hudStatic(); hudT = 0; if (inGame) toast(T('Captain: every garden is open for testing')); + } + if (window.BackRoomCaptains) { BackRoomCaptains.onChange(captainCheck); if (BackRoomCaptains.ready) BackRoomCaptains.ready.then(captainCheck); } var p = { x: WR.SPAWN.x, z: WR.SPAWN.z, y: 0, vy: 0, vx: 0, vz: 0, yaw: 0, pitch: -0.25, ground: true, eye: 1.62, bob: 0, stepD: 0 }; if (state.pos && !WR.solidAt(state.pos.x, state.pos.z)) { p.x = state.pos.x; p.z = state.pos.z; p.yaw = state.pos.yaw || 0; } function resize() { var w = canvas.clientWidth || innerWidth, h = canvas.clientHeight || innerHeight; renderer.setSize(w, h, false); camera.aspect = vm.cam.aspect = w / h; camera.fov = w < h ? 84 : 72; camera.updateProjectionMatrix(); vm.cam.updateProjectionMatrix(); needRender = true; } @@ -85,11 +105,11 @@ { id: 'kneel', label: 'Kneel', note: 'After you earn the knee pads', group: 'Move', keys: ['KeyC'] }, { id: 'use', label: 'Empty sack or open a gate', group: 'Work', keys: ['KeyE'] }, { id: 'tool1', label: 'Hands', group: 'Work', keys: ['Digit1'] }, { id: 'tool2', label: 'Rake', group: 'Work', keys: ['Digit2'] }, { id: 'tool3', label: 'Blower', group: 'Work', keys: ['Digit3'] }, - { id: 'next', label: 'Next tool', group: 'Work', keys: ['KeyQ'] }, { id: 'find', label: 'Leaf finder', group: 'Work', keys: ['KeyF'] }, + { id: 'next', label: 'Next tool', group: 'Work', keys: ['KeyQ'] }, { id: 'rakeMode', label: 'Rake: pull or push', note: 'After you buy rake push', group: 'Work', keys: ['KeyR'] }, { id: 'find', label: 'Leaf finder', group: 'Work', keys: ['KeyF'] }, { id: 'journal', label: 'Journal and shed', group: 'Work', keys: ['Tab', 'KeyJ'] }, { id: 'pause', label: 'Pause', group: 'Work', keys: ['Escape'], fixed: true } ], classes: { button: 'btn sm', primary: 'btn sm go' } }); var keys = new Set(), useHeld = false, mouseUse = false, touchUse = false, stick = { x: 0, y: 0, id: -1 }, lookId = -1, lookX = 0, lookY = 0, sprintT = false, kneelT = false, wasLocked = false; - var ov = ['title'], inGame = false; + var ov = ['title'], inGame = false, lockedAt = 0; function playing() { return inGame && !ov.length; } function setTouch() { if (touchUI) return; touchUI = true; document.body.classList.add('touch'); $('howTouch').hidden = false; hudStatic(); hudT = 0; } addEventListener('touchstart', setTouch, { passive: true }); @@ -108,24 +128,27 @@ if (KB.is('tool1', e.code)) setTool(0); if (KB.is('tool2', e.code)) setTool(1); if (KB.is('tool3', e.code)) setTool(2); if (KB.is('next', e.code)) nextTool(1); if (KB.is('find', e.code)) toggleFinder(); + if (KB.is('rakeMode', e.code)) flipRake(); }); addEventListener('keyup', function (e) { keys.delete(e.code); }); addEventListener('blur', function () { keys.clear(); mouseUse = false; }); canvas.addEventListener('mousedown', function (e) { if (!playing() || touchUI) return; Au.init(); - if (document.pointerLockElement !== canvas) { lock(); if (e.button === 0) mouseUse = true; return; } - if (e.button === 0) mouseUse = true; + if (document.pointerLockElement !== canvas) { lock(); if (e.button === 0) { mouseUse = true; grabQ = true; } return; } + if (e.button === 0) { mouseUse = true; grabQ = true; } }); addEventListener('mouseup', function (e) { if (e.button === 0) mouseUse = false; }); addEventListener('mousemove', function (e) { if (!playing() || document.pointerLockElement !== canvas) return; + // some browsers send one huge jump just as the pointer locks: ignore the first moment, and any single absurd jump + if (performance.now() - lockedAt < 120 || Math.abs(e.movementX) > 250 || Math.abs(e.movementY) > 250) return; look(e.movementX * 0.0022, e.movementY * 0.0022); }); canvas.addEventListener('wheel', function (e) { if (playing()) nextTool(e.deltaY > 0 ? 1 : -1); }, { passive: true }); function look(dx, dy) { var s = state.set.sens; p.yaw -= dx * s; p.pitch -= dy * s * (state.set.inv ? -1 : 1); if (p.pitch > 1.45) p.pitch = 1.45; if (p.pitch < -1.45) p.pitch = -1.45; } function lock() { if (touchUI || !canvas.requestPointerLock) return; try { var r = canvas.requestPointerLock(); if (r && r.catch) r.catch(function () {}); } catch (e) {} } document.addEventListener('pointerlockchange', function () { - if (document.pointerLockElement === canvas) wasLocked = true; + if (document.pointerLockElement === canvas) { wasLocked = true; lockedAt = performance.now(); } else if (wasLocked && playing() && !touchUI) { wasLocked = false; pause(); } }); // touch: left stick walks, a drag anywhere else looks, Use is held (and still looks while held) @@ -147,7 +170,8 @@ canvas.addEventListener('pointermove', function (e) { if (e.pointerId !== lookId) return; look((e.clientX - lookX) * 0.0052, (e.clientY - lookY) * 0.0052); lookX = e.clientX; lookY = e.clientY; }); function lend(e) { if (e.pointerId === lookId) lookId = -1; } canvas.addEventListener('pointerup', lend); canvas.addEventListener('pointercancel', lend); - bindHold($('tUse'), function () { touchUse = true; }, function () { touchUse = false; }, true); + bindHold($('tUse'), function () { touchUse = true; grabQ = true; }, function () { touchUse = false; }, true); + bindHold($('tMode'), function () { flipRake(); }); bindHold($('tJump'), function () { jump(); }, null, true); bindHold($('tSprint'), function () { sprintT = !sprintT; if (sprintT) kneelT = false; touchToggles(); }); bindHold($('tKneel'), function () { kneelT = !kneelT; if (kneelT) sprintT = false; touchToggles(); }); @@ -200,28 +224,38 @@ if (tool !== 1) vm.poseRake(tmp, tmp2, camera.position, rx, rz, false); var raise = Math.min(1, toolT * 5); if (tool === 0) { - // where the hands reach: where you are looking on the ground, no farther than an arm and a bit - var reach = HAND_REACH[state.up.hands], maxD = 2.3 + reach * 0.4, d = maxD; - if (fwd.y < -0.05) d = Math.min(maxD, Math.max(0.5, (p.y + p.eye) / -fwd.y * Math.hypot(fwd.x, fwd.z))); + // one grab a click or tap: the leaves in a small circle where you are looking go into the sack. Bigger handfuls + // widens the circle; Steady hands (a later upgrade) keeps grabbing while the button is held. + var reach = GRAB_R[state.up.hands], maxD = 2.5, d = maxD; + if (fwd.y < -0.05) d = Math.min(maxD, Math.max(0.45, (p.y + p.eye) / -fwd.y * Math.hypot(fwd.x, fwd.z))); var tx = p.x + fx2 * d, tz = p.z + fz2 * d; - vm.ring.visible = true; vm.ring.position.set(tx, 0.035, tz); vm.ring.scale.setScalar(reach); + vm.ring.visible = true; vm.ring.position.set(tx, 0.04, tz); vm.setRing(reach); var per = leaves.fill[curArea], room = Math.floor((cap - state.bagFill) / per + 1e-6); - if (using) { - if (room <= 0) { fullT -= dt; if (fullT <= 0) { fullT = 2.5; Au.full(); $('hBag').classList.remove('shake'); void $('hBag').offsetWidth; $('hBag').classList.add('shake'); } } + grabT -= dt; + var want = grabQ || (using && state.up.hold && grabT <= -(HOLD_GAP - GRAB_GAP)); + if (want && grabT <= 0) { + grabQ = false; grabT = GRAB_GAP; + if (room <= 0) { Au.full(); $('hBag').classList.remove('shake'); void $('hBag').offsetWidth; $('hBag').classList.add('shake'); } else { - handAcc += HAND_RATE[state.up.hands] / per * (kneeling ? 2 : 1) * dt * 1.15; var n = Math.floor(handAcc); - if (n > 0) { handAcc -= n; var took = leaves.scoop(tx, tz, reach, Math.min(n, room), p.x, p.z, leaves.alive[curArea] <= 6); if (took) { handAnim = 1; if (!state.seen.grab && state.bagFill >= cap * 0.5) { state.seen.grab = 1; hudT = 0; } } } + // the circle always takes at least the one leaf nearest its middle, so the very first grab is never empty-handed + var last = leaves.alive[curArea] <= 24, took = leaves.scoop(tx, tz, reach, Math.min(room, 400), p.x, p.z, last); + if (!took) took = leaves.scoop(tx, tz, 0.45, 1, p.x, p.z, last); + if (took) { handAnim = 1; Au.grab(Math.min(1, took / 25)); if (!state.seen.intro) { state.seen.intro = 1; hudT = 0; } if (!state.seen.grab && state.bagFill >= cap * 0.5) { state.seen.grab = 1; hudT = 0; } } + else Au.miss(); } - } else handAcc = 0; + } handAnim = Math.max(0, handAnim - dt * 3); - var sw = using ? Math.sin(toolT * 13) : 0; + var sw = 0; vm.rh.position.set(0.17 - handAnim * 0.04, -0.19 - (using ? 0.04 : 0) + sw * 0.025 + (raise - 1) * 0.3, -0.5 - (using ? 0.08 : 0) - sw * 0.04); vm.sack.position.y = -0.4 + handAnim * 0.025 + (raise - 1) * 0.3; - vm.ring.material.opacity = using ? 0.8 : 0.4; + vm.ring.material.opacity = 0.45 + handAnim * 0.45; } else if (tool === 1) { // a stroke: reach out with the head lifted, drop it, drag it back along the ground var W = RAKE_W[state.up.rakeW], near = 0.95, far = 2.75, dist, lift, pulling = false; - if (using) { rakeT += dt; var ph = rakeT % 0.8; if (ph < 0.28) { var u = ph / 0.28; dist = near + (far - near) * u; lift = 0.3 * Math.sin(u * Math.PI) + 0.04; } else { var u2 = (ph - 0.28) / 0.52; dist = far - (far - near) * (1 - (1 - u2) * (1 - u2)); lift = 0; pulling = true; } } + var push = state.rakeMode === 'push' && state.up.rakePush; + if (using && !push) { rakeT += dt; var ph = rakeT % 0.8; if (ph < 0.28) { var u = ph / 0.28; dist = near + (far - near) * u; lift = 0.3 * Math.sin(u * Math.PI) + 0.04; } else { var u2 = (ph - 0.28) / 0.52; dist = far - (far - near) * (1 - (1 - u2) * (1 - u2)); lift = 0; pulling = true; } } + // pushing: the head goes down close in, slides out along the ground, then lifts and comes back + else if (using) { rakeT += dt; var ph2 = rakeT % 0.8; if (ph2 < 0.52) { var u3 = ph2 / 0.52; dist = near + (far - near) * (1 - (1 - u3) * (1 - u3)); lift = 0; pulling = true; } else { var u4 = (ph2 - 0.52) / 0.28; dist = far - (far - near) * u4; lift = 0.3 * Math.sin(u4 * Math.PI) + 0.04; } } else { rakeT = 0; dist = 1.5; lift = 0.1; } var free = leaves.freeDist(p.x, p.z, fx2, fz2, dist + 0.2) - 0.2; if (dist > free) dist = Math.max(0.5, free); var hx = p.x + fx2 * dist, hz = p.z + fz2 * dist; @@ -252,7 +286,12 @@ if (tool !== 2) vm.wind(dt, false); vm.hands.position.y = tool === 0 ? Math.sin(p.bob) * 0.008 : 0; } - var grabbed = 0, raked = 0, strokeHits = 0; + var raked = 0, strokeHits = 0, grabQ = false, grabT = 0; + function flipRake() { + if (!state.up.rakePush) { if (state.up.rake) { toast(T('Buy rake push in the shed to push leaves away'), false, 4); Au.no(); } return; } + state.rakeMode = state.rakeMode === 'push' ? 'pull' : 'push'; dirty = true; Au.click(); hudStatic(); + toast(T(state.rakeMode === 'push' ? 'Rake: push' : 'Rake: pull')); + } /* ---------- bins, gates, money ---------- */ var gainAcc = 0, gainT = 0, prompt = null; @@ -261,7 +300,7 @@ function findPrompt() { var best = null, i, d; if (state.bagFill > 0.01) for (i = 0; i < WR.BINS.length; i++) { var b = WR.BINS[i]; d = Math.hypot(b.x - p.x, b.z - p.z); if (d < 2.6 && (!best || d < best.d)) best = { type: 'bin', i: i, d: d, ok: true, text: T('Empty your sack') }; } - for (i = 0; i < WR.GATES.length; i++) { var g = WR.GATES[i], a = A[g.area]; if (state.unlocked[g.area]) continue; d = Math.hypot(g.x - p.x, g.z - p.z); if (d > (g.area === 0 ? 2.3 : 3.6) || (best && best.d < d)) continue; + for (i = 0; i < WR.GATES.length; i++) { var g = WR.GATES[i], a = A[g.area]; if (isOpen(g.area)) continue; d = Math.hypot(g.x - p.x, g.z - p.z); if (d > (g.area === 0 ? 2.3 : 3.6) || (best && best.d < d)) continue; if (g.area === 0) { best = { type: 'gate', d: d, ok: false, text: T('Clear every leaf in the yard and this gate opens') }; continue; } var need = a.need && leaves.share(a.need[0]) < a.need[1]; best = need ? { type: 'gate', d: d, ok: false, text: T('Clear half of {a} to open this gate', { a: T(A[a.need[0]].name) }) } @@ -287,7 +326,7 @@ function unlock(ai) { var a = A[ai]; if (state.unlocked[ai] || state.acorns < a.cost) { Au.no(); return false; } if (a.need && leaves.share(a.need[0]) < a.need[1]) { Au.no(); return false; } - state.acorns -= a.cost; state.unlocked[ai] = 1; WR.openGate(ai); world.gates.forEach(function (G) { if (G.def.area === ai) G.target = 1; }); world.refreshSigns(state); + state.acorns -= a.cost; state.unlocked[ai] = 1; WR.openGate(ai); world.gates.forEach(function (G) { if (G.def.area === ai) G.target = 1; }); world.refreshSigns(openView()); Au.gate(); Au.buy(); toast(T('{a} is open', { a: T(a.name) }), true); acDirty = true; hudStatic(); save(); return true; } function buy(id) { @@ -295,17 +334,19 @@ if (u.needs && !state.up[u.needs]) return; var c = u.costs[lv]; if (state.acorns < c) { Au.no(); return; } state.acorns -= c; state.up[id]++; Au.buy(); acDirty = bagDirty = true; vm.refresh(); state.seen.shop = 1; - if (id === 'rake') { tool = state.tool = 1; toolT = 0; say(T('Bought the rake: hold to drag leaves into a pile'), 14); } else if (id === 'blower') { tool = state.tool = 2; toolT = 0; say(T('Bought the blower: hold to push leaves away'), 12); } else toast(T(u.name) + ' ✓'); + if (id === 'rake') { tool = state.tool = 1; toolT = 0; say(T('Bought the rake: hold to drag leaves into a pile'), 14); } else if (id === 'blower') { tool = state.tool = 2; toolT = 0; say(T('Bought the blower: hold to push leaves away'), 12); } + else if (id === 'rakePush') { state.rakeMode = 'push'; tool = state.tool = 1; toolT = 0; say(touchUI ? T('Rake push: tap Push or Pull to switch') : T('Rake push: press {k} to switch between pull and push', { k: KB.short('rakeMode') }), 12); } + else if (id === 'hold') { say(touchUI ? T('Steady hands: hold Grab to keep picking up') : T('Steady hands: hold the mouse button to keep picking up'), 10); } else toast(T(u.name) + ' ✓'); hudStatic(); pulse(id === 'sack' || id === 'hands' ? 'hBag' : 'hTools'); save(); renderJournal(); } function checkDone() { for (var i = 0; i < A.length; i++) { - if (!state.unlocked[i] || state.done[i]) continue; + if (!isOpen(i) || state.done[i]) continue; if (leaves.alive[i] > 0 || state.bagUnits[i] > 1e-6) continue; state.done[i] = 1; var a = A[i]; state.acorns += a.bonus; state.earned += a.bonus; state.rewards[a.reward] = 1; acDirty = true; // the Front Yard's reward is the gate itself: Gatehouse Court opens, free - if (i === WR.YARD && !state.unlocked[0]) { state.unlocked[0] = 1; WR.openGate(0); world.gates.forEach(function (G) { if (G.def.area === 0) G.target = 1; }); world.refreshSigns(state); Au.gate(); say(T('The gate is open: the next garden is waiting'), 12); } + if (i === WR.YARD && !state.unlocked[0]) { state.unlocked[0] = 1; WR.openGate(0); world.gates.forEach(function (G) { if (G.def.area === 0) G.target = 1; }); world.refreshSigns(openView()); Au.gate(); say(T('The gate is open: the next garden is waiting'), 12); } toast(T('{a} is clear!', { a: T(a.name) }) + '' + T('+{n} acorns', { n: a.bonus }) + ' · ' + T(a.rewardName) + ': ' + T(rewardText(a)) + '', true, 7); Au.fanfare(); vm.refresh(); hudStatic(); save(); celebrate(a); } @@ -322,7 +363,7 @@ function toggleFinder() { finder = !finder; $('tFind').classList.toggle('on', finder); toast(T(finder ? 'Leaf finder on: lights mark the nearest leaves' : 'Leaf finder off')); findT = 0; } function updateFinder(dt) { findT -= dt; if (findT > 0) return; findT = 0.4; - var auto = leaves.alive[curArea] > 0 && leaves.alive[curArea] <= Math.max(6, leaves.counts[curArea] * 0.03), on = (finder || auto) && state.unlocked[curArea]; + var auto = leaves.alive[curArea] > 0 && leaves.alive[curArea] <= Math.max(6, leaves.counts[curArea] * 0.03), on = (finder || auto) && isOpen(curArea); if (on) leaves.nearest(p.x, p.z, curArea, 8, near); else near.length = 0; for (var i = 0; i < 8; i++) { var b = vm.beacons[i]; if (i * 3 < near.length) { b.visible = true; b.position.set(near[i * 3], 0, near[i * 3 + 1]); } else b.visible = false; } } @@ -342,9 +383,12 @@ $('hTools').hidden = !tools; Array.prototype.forEach.call(document.querySelectorAll('.slot'), function (b) { var t = +b.dataset.tool; b.classList.toggle('on', t === tool); b.hidden = !owns(t); }); $('tSprint').hidden = !state.rewards.sprint; $('tKneel').hidden = !state.rewards.crouch; + $('tUse').textContent = T(['Grab', 'Rake', 'Blow'][tool]); + $('tMode').hidden = !(tool === 1 && state.up.rakePush); $('tMode').textContent = T(state.rakeMode === 'push' ? 'Pull' : 'Push'); + var pushOwned = tool === 1 && state.up.rakePush; $('rakeMode').hidden = !pushOwned || touchUI; if (pushOwned) $('rakeMode').innerHTML = '' + KB.short('rakeMode') + '' + T(state.rakeMode === 'push' ? 'Rake pushes' : 'Rake pulls'); $('hShed').hidden = $('tJournal').hidden = !shedOpen(); $('hShedKey').textContent = shedKey(); - $('tFind').hidden = !state.unlocked[0]; - $('hArea').hidden = !shedOpen(); $('arName').hidden = !state.unlocked[0]; + $('tFind').hidden = !isOpen(0); + $('hArea').hidden = !shedOpen() && !capOpen; $('arName').hidden = false; $('pJournal').hidden = !shedOpen(); $('howKeys').textContent = T('{m} to walk, mouse to look, hold the left button to work, {j} to jump. {a} to switch tools, {e} at a bin or gate, {t} for the shed and map, {f} for the leaf finder.', { m: KB.label(['fwd', 'left', 'back', 'right'], ' ', '', 1), j: KB.short('jump'), a: '1 2 3', e: KB.short('use'), t: shedKey(), f: KB.short('find') }); } @@ -354,16 +398,16 @@ var cap = SACK[state.up.sack]; if (sayT > 0) return sayTxt; if (state.bagFill >= cap - 0.5) return T('Your sack is full: empty it in the bin'); - if (!state.seen.grab) return touchUI ? T('Hold Use to gather leaves') : T('Hold the left mouse button to gather leaves'); + if (!state.seen.grab) return touchUI ? T('Tap Grab to pick up the leaves in the circle') : T('Click to pick up the leaves in the circle'); if (!shedOpen()) return null; if (!state.seen.shop && state.acorns >= UP[1].costs[0]) return touchUI ? T('Tap the shed button to spend your acorns') : T('Press {k} to spend your acorns in the shed', { k: shedKey() }); - if (!state.up.rake && state.acorns >= UP[2].costs[0]) return touchUI ? T('You can afford the rake: tap the shed button') : T('You can afford the rake: press {k}', { k: shedKey() }); + if (!state.up.rake && state.acorns >= UP.filter(function (u) { return u.id === 'rake'; })[0].costs[0]) return touchUI ? T('You can afford the rake: tap the shed button') : T('You can afford the rake: press {k}', { k: shedKey() }); return null; } function hud(dt) { hudT -= dt; gainT -= dt; sayT -= dt; if (acDirty) { acDirty = false; var el = $('acN'); el.textContent = Math.floor(state.acorns); el.classList.remove('pop'); void el.offsetWidth; el.classList.add('pop'); } - if (bagDirty) { bagDirty = false; var cap = SACK[state.up.sack], f = Math.min(1, state.bagFill / cap); $('bagBar').style.width = (f * 100) + '%'; $('bagN').textContent = Math.min(cap, Math.round(state.bagFill)) + '/' + cap; $('hBag').classList.toggle('full', f >= 0.985); vm.refresh(); } + if (bagDirty) { bagDirty = false; var cap = SACK[state.up.sack], f = Math.min(1, state.bagFill / cap); $('bagBar').style.width = (f * 100) + '%'; $('bagN').textContent = Math.min(cap, Math.ceil(state.bagFill - 0.05)) + '/' + cap; $('hBag').classList.toggle('full', f >= 0.985); vm.refresh(); } var g = $('gain'); if (gainT > 0) { g.textContent = '+' + (gainAcc < 10 ? gainAcc.toFixed(1) : Math.round(gainAcc)); g.classList.add('on'); } else if (gainAcc) { gainAcc = 0; g.classList.remove('on'); } // the marker over the bin: while the sack is nearly full, and until the first sack has been emptied if (vm.marker.visible) { markT += dt; vm.marker.position.y = 2.2 + Math.abs(Math.sin(markT * 3.2)) * 0.35; vm.marker.rotation.y += dt * 2; } @@ -375,7 +419,9 @@ al.hidden = !show; if (show) al.textContent = left > 0 ? T(left === 1 ? '1 leaf left' : '{n} leaves left', { n: left }) : T('The last leaves are in your sack'); prompt = findPrompt(); var hp = $('hPrompt'), ta = $('tAct'), hint = $('hint'), cap2 = SACK[state.up.sack]; - if (prompt) { hp.hidden = false; hp.classList.toggle('act', !!prompt.ok); hp.innerHTML = (prompt.ok ? '' + KB.short('use') + '' : '') + prompt.text; ta.hidden = !prompt.ok; if (prompt.ok) ta.textContent = prompt.text; hint.hidden = true; } + if (prompt && (state.seen.intro || !inGame)) { hp.hidden = false; hp.classList.toggle('act', !!prompt.ok); hp.innerHTML = (prompt.ok ? '' + KB.short('use') + '' : '') + prompt.text; ta.hidden = !prompt.ok; if (prompt.ok) ta.textContent = prompt.text; hint.hidden = true; } + var intro = $('intro'), showIntro = inGame && !state.seen.intro && !$('toasts').children.length; // never on screen with a notification intro.hidden = !showIntro; if (showIntro) { $('introDo').textContent = touchUI ? T('Start here: tap Grab to pick up the leaves at your feet.') : T('Start here: click to pick up the leaves at your feet.'); } + if (showIntro) { hp.hidden = true; ta.hidden = true; hint.hidden = true; } else { hp.hidden = true; ta.hidden = true; var tx = hintText(); hint.hidden = !tx; if (tx && hint.textContent !== tx) { hint.textContent = tx; pulse('hint'); } } var needBin = state.bagFill >= cap2 * (state.seen.bin ? 0.985 : 0.6), mk = vm.marker; if (needBin) { var best = null, bd = 1e9; WR.BINS.forEach(function (b) { var d = Math.hypot(b.x - p.x, b.z - p.z) + (b.area === curArea ? 0 : 60); if (d < bd) { bd = d; best = b; } }); mk.visible = bd > 2.2; mk.position.x = best.x; mk.position.z = best.z; } else mk.visible = false; @@ -397,7 +443,7 @@ } function pause() { if (!playing()) return; open('pause'); } function resume() { ov.length = 0; inGame = true; showOv(); Au.init(); lock(); last = performance.now(); hudStatic(); acDirty = bagDirty = true; hudT = 0; } - $('playBtn').addEventListener('click', function () { world.refreshSigns(state); resume(); }); + $('playBtn').addEventListener('click', function () { world.refreshSigns(openView()); resume(); }); $('resumeBtn').addEventListener('click', function () { closeTop(); }); $('pHow').addEventListener('click', function () { open('how'); }); $('setBtn').addEventListener('click', function () { open('settings'); }); $('pSet').addEventListener('click', function () { open('settings'); }); @@ -422,12 +468,12 @@ // journal: the map, the gardens and the shed var tab = 'shed'; // the shed shows what is useful now: three things at first, more as tools and gardens arrive - function shedShows(u) { if (u.id === 'sack' || u.id === 'hands' || u.id === 'rake') return true; if (u.id === 'blower') return !!state.unlocked[0]; if (u.needs) return !!state.up[u.needs]; return !!state.up.rake; } + function shedShows(u) { if (u.id === 'sack' || u.id === 'hands' || u.id === 'rake') return true; if (u.id === 'hold') return !!state.up.rake; if (u.id === 'blower') return isOpen(0); if (u.needs) return !!state.up[u.needs]; return !!state.up.rake; } Array.prototype.forEach.call(document.querySelectorAll('.tabs .btn'), function (b) { b.addEventListener('click', function () { tab = b.dataset.tab; renderJournal(); Au.click(); }); }); function pips(lv, max) { var s = ''; for (var i = 0; i < max; i++) s += ''; return s + ''; } function renderJournal() { if (ov[ov.length - 1] !== 'journal') return; - var maps = !!state.unlocked[0]; if (!maps) tab = 'shed'; + var maps = isOpen(0); if (!maps) tab = 'shed'; Array.prototype.forEach.call(document.querySelectorAll('.tabs .btn'), function (b) { b.classList.toggle('on', b.dataset.tab === tab); b.hidden = !maps; }); $('jBody').classList.toggle('solo', !maps); $('jNote').hidden = !maps; $('jTitle').hidden = maps; $('jPurse').textContent = Math.floor(state.acorns) + ' ' + T('acorns'); @@ -465,19 +511,19 @@ g.fillStyle = 'rgba(207,233,238,.9)'; WR.GLASS.forEach(function (h) { g.fillRect(X(h[0]), Z(h[2]), (h[1] - h[0]) * S, (h[3] - h[2]) * S); }); g.fillStyle = '#3c6a36'; WR.HEDGES.forEach(function (h) { g.fillRect(X(h[0]), Z(h[2]), (h[1] - h[0]) * S, (h[3] - h[2]) * S); }); g.fillStyle = 'rgba(190,110,40,.55)'; WR.TREES.forEach(function (t) { g.beginPath(); g.arc(X(t[0]), Z(t[1]), 13 * t[2], 0, 7); g.fill(); }); - g.fillStyle = 'rgba(107,61,28,.8)'; leaves.eachAlive(function (x, z, ar) { if (state.unlocked[ar]) g.fillRect(X(x) - 1, Z(z) - 1, 2.2, 2.2); }, leaves.N > 30000 ? 3 : 2); + g.fillStyle = 'rgba(107,61,28,.8)'; leaves.eachAlive(function (x, z, ar) { if (isOpen(ar)) g.fillRect(X(x) - 1, Z(z) - 1, 2.2, 2.2); }, leaves.N > 30000 ? 3 : 2); WR.CHUTES.forEach(function (ch) { g.fillStyle = '#e0b53a'; g.fillRect(X(ch.x) - 8, Z(ch.z) - 8, 16, 16); g.fillStyle = '#17130f'; g.fillRect(X(ch.x) - 5, Z(ch.z) - 5, 10, 10); }); WR.BINS.forEach(function (b) { g.fillStyle = '#6f4a2a'; g.fillRect(X(b.x) - 7, Z(b.z) - 7, 14, 14); g.fillStyle = '#e2572f'; g.beginPath(); g.moveTo(X(b.x), Z(b.z) - 20); g.lineTo(X(b.x) + 13, Z(b.z) - 14); g.lineTo(X(b.x), Z(b.z) - 8); g.fill(); g.fillRect(X(b.x) - 1, Z(b.z) - 20, 2, 16); }); g.textAlign = 'center'; g.font = '800 17px Nunito, sans-serif'; A.forEach(function (a, i) { var cx = X((a.x0 + a.x1) / 2), cz = Z((a.z0 + a.z1) / 2); - if (!state.unlocked[i]) { g.fillStyle = 'rgba(40,32,20,.55)'; g.fillRect(X(a.x0) + 3, Z(a.z0) + 3, (a.x1 - a.x0) * S - 6, (a.z1 - a.z0) * S - 6); } - var label = T(a.name), sub = state.unlocked[i] ? (state.done[i] ? '✓ 100%' : Math.floor(leaves.share(i) * 100) + '%') : T('Locked') + ' · ' + a.cost, w = Math.max(g.measureText(label).width, g.measureText(sub).width) + 16; + if (!isOpen(i)) { g.fillStyle = 'rgba(40,32,20,.55)'; g.fillRect(X(a.x0) + 3, Z(a.z0) + 3, (a.x1 - a.x0) * S - 6, (a.z1 - a.z0) * S - 6); } + var label = T(a.name), sub = isOpen(i) ? (state.done[i] ? '✓ 100%' : Math.floor(leaves.share(i) * 100) + '%') : T('Locked') + ' · ' + a.cost, w = Math.max(g.measureText(label).width, g.measureText(sub).width) + 16; g.fillStyle = 'rgba(246,236,212,.9)'; g.fillRect(cx - w / 2, cz - 24, w, 46); g.fillStyle = '#2e2416'; g.fillText(label, cx, cz - 5); g.fillStyle = state.done[i] ? '#3f6b52' : '#c4552d'; g.fillText(sub, cx, cz + 15); }); g.save(); g.translate(X(p.x), Z(p.z)); g.rotate(-p.yaw); g.fillStyle = '#fff'; g.strokeStyle = '#1d3b6a'; g.lineWidth = 3; g.beginPath(); g.moveTo(0, -13); g.lineTo(9, 10); g.lineTo(0, 5); g.lineTo(-9, 10); g.closePath(); g.fill(); g.stroke(); g.restore(); } - document.addEventListener('backroom:lang', function () { world.refreshSigns(state); hudStatic(); titleText(); renderJournal(); hudT = 0; }); + document.addEventListener('backroom:lang', function () { world.refreshSigns(openView()); hudStatic(); titleText(); renderJournal(); hudT = 0; }); /* ---------- the frame ---------- */ var last = performance.now(), frameN = 0, slowT = 0, avgMs = 16, magT = 0; @@ -514,8 +560,8 @@ document.addEventListener('visibilitychange', function () { if (document.hidden) { if (dirty || playing()) save(); Au.suspend(true); if (playing()) pause(); } else Au.suspend(false); }); addEventListener('pagehide', function () { if (inGame) save(); }); Au.vol = state.set.vol; world.bins.forEach(function (B) { B.heap.scale.y = 0.3 + (state.binFill || 0) * 0.9; }); - hudStatic(); titleText(); showOv(); world.refreshSigns(state); - if (document.fonts && document.fonts.ready) document.fonts.ready.then(function () { world.refreshSigns(state); }); + hudStatic(); titleText(); showOv(); world.refreshSigns(openView()); captainCheck(); + if (document.fonts && document.fonts.ready) document.fonts.ready.then(function () { world.refreshSigns(openView()); }); requestAnimationFrame(frame); // for the test scripts only (nothing in the game calls these) @@ -524,6 +570,7 @@ bench: function (steps) { var t0 = performance.now(), mx = 0, sum = 0; for (var i = 0; i < steps; i++) { update(1 / 60); var a = leaves.awakeCount(); sum += a; if (a > mx) mx = a; } return { ms: (performance.now() - t0) / steps, maxAwake: mx, avgAwake: Math.round(sum / steps), n: leaves.N }; }, refresh: function () { hudStatic(); }, beacons: function () { return vm.beacons.filter(function (b) { return b.visible; }).length; }, step: function (n, dt) { for (var i = 0; i < n; i++) update(dt || 1 / 60); }, + captain: function () { capOpen = false; captainCheck(); return capOpen; }, grab: function () { grabQ = true; }, isOpen: isOpen, tool: setTool, give: function (n) { state.acorns += n; acDirty = true; }, buy: buy, unlock: unlock, interact: interact, open: open, close: closeTop, save: save, touch: setTouch, say: say, info: function () { return { hint: $('hint').hidden ? null : $('hint').textContent, awake: leaves.awakeCount(), n: leaves.N, alive: leaves.alive.slice(), acorns: state.acorns, bag: state.bagFill, playing: playing(), prompt: prompt && prompt.text }; } }; })(); diff --git a/e63334287a3deaa3/windrow/js/models.js b/e63334287a3deaa3/windrow/js/models.js index 323e16a9..34a36c30 100644 --- a/e63334287a3deaa3/windrow/js/models.js +++ b/e63334287a3deaa3/windrow/js/models.js @@ -91,6 +91,10 @@ }; // the ring that shows where the hands reach var ring = vm.ring = new THREE.Mesh(new THREE.RingGeometry(.955, 1, 48), new THREE.MeshBasicMaterial({ color: 0xffffff, transparent: true, opacity: .5, depthWrite: false, fog: false })); ring.rotation.x = -Math.PI / 2; ring.visible = false; scene.add(ring); + // the grab circle keeps a rim about 3 cm wide and a faint fill, whatever its size, so even the smallest one shows + var ringR = -1, disc = new THREE.Mesh(new THREE.CircleGeometry(1, 40), new THREE.MeshBasicMaterial({ color: 0xffffff, transparent: true, opacity: .1, depthWrite: false, fog: false })); disc.position.z = -.002; ring.add(disc); + ring.material.depthTest = false; disc.material.depthTest = false; ring.renderOrder = disc.renderOrder = 5; // drawn over the leaves, which would hide it in a deep carpet + vm.setRing = function (r) { if (Math.abs(r - ringR) < 1e-4) return; ringR = r; ring.geometry.dispose(); ring.geometry = new THREE.RingGeometry(Math.max(.02, r - .03), r, 48); disc.scale.setScalar(r - .03); }; // finder beacons vm.beacons = []; var bg = new THREE.CylinderGeometry(.05, .05, 7, 6, 1, true); bg.translate(0, 3.5, 0); var bm = new THREE.MeshBasicMaterial({ color: lin('#ffe27a'), transparent: true, opacity: .5, depthWrite: false, fog: false }); for (i = 0; i < 8; i++) { var be = new THREE.Mesh(bg, bm); be.visible = false; scene.add(be); vm.beacons.push(be); } diff --git a/e63334287a3deaa3/windrow/js/world.js b/e63334287a3deaa3/windrow/js/world.js index 517e0e7c..d34b815e 100644 --- a/e63334287a3deaa3/windrow/js/world.js +++ b/e63334287a3deaa3/windrow/js/world.js @@ -70,11 +70,11 @@ /* The Front Yard: a small buried lawn with a stone path, between the garden house and Gatehouse Court. Written in real metres (not scaled). Finishing it opens the gate to the court by itself. `dense` thickens its leaves. */ var YARD = { x0: -4, x1: 4, z0: 16, z1: 23 }, HOUSE = { x0: -5, x1: 5, z0: 23.25, z1: 28.45 }, PATHS = [[-0.9, 0.9, 16.25, 23]], POTS = [[-1.3, 22.7], [1.3, 22.7]]; - WR.AREAS.push({ id: 'yard', name: 'Front Yard', x0: YARD.x0, x1: YARD.x1, z0: YARD.z0, z1: YARD.z1, ground: LAWN, leaves: 220, units: 140, cost: 0, need: null, bonus: 30, dense: 1.5, + WR.AREAS.push({ id: 'yard', name: 'Front Yard', x0: YARD.x0, x1: YARD.x1, z0: YARD.z0, z1: YARD.z1, ground: LAWN, leaves: 170, units: 120, cost: 0, need: null, bonus: 30, dense: 1.5, reward: 'gate', rewardName: 'The garden gate', rewardText: 'Gatehouse Court is open', pal: ['#d9a23a', '#cf7a2a', '#b8552a', '#e6c04e', '#9a5a2a'] }); WR.YARD = 5; WR.ORDER = [5, 0, 1, 2, 3, 4]; WR.GATES.push({ area: 0, axis: 'x', x: 0, z: 16 }); - WR.BINS.push({ area: 5, x: 2.9, z: 17.35 }); + WR.BINS.push({ area: 5, x: 2.9, z: 16.95 }); // flush against the wall: a gap behind a bin traps leaves TREES.push([-2.9, 18.2, 0.62]); WR.SPAWN = { x: 0, z: 21.9, yaw: 0 }; WR.HOUSE = HOUSE; WR.PATHS = PATHS; WR.HEDGES = HEDGES; WR.GLASS = GLASS; WR.POND = POND; WR.FOUNTAIN = FOUNTAIN;