diff --git a/README.md b/README.md index dc1b3494..37e95310 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 garden** is flat, about 61 x 40 m, on one grid of 0.25 m cells (`WR.CELL`, 248 x 168; 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 gardens are `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); High also turns on a real shadow map, drawn once (nothing that casts a shadow moves, except a gate opening). 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. **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), `rewards`, `bagUnits` (what is in the sack, per garden) and `bagFill`, `gone` (share of each garden cleared), `tool`, `tut` (tutorial step), `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 scripted player clears the yard in about 100 game-seconds, with the first upgrade after the first sack and the rake after the third. **The garden** is flat, about 61 x 53 m, on one grid of 0.25 m cells (`WR.CELL`, 248 x 216; the plan in `world.js` is written at full size and every position is then multiplied by `WR.S` = 0.8, so the gardens are small and the leaves lie thick): `solid` blocks the player and the leaves, `gtype` is the surface (lawn, paving, decking, gravel: how far a leaf slides), `inlet` marks mulch-chute cells, `areaOf` says which garden a cell belongs to. The five big gardens are the first entries of `WR.AREAS` in `world.js` (Gatehouse Court, Orchard Walk, Lily Terrace, Glasshouse Row, Maze Lawn) with their gate cost, the garden that must be half cleared first, the bonus and the reward for finishing (sprint, kneel, higher jump, chutes that draw leaves in, a gold rake); bins, chutes, gates, trees, hedges and benches are lists just under it, and `WR.buildGrid` turns them into the grid, so moving a prop means editing its list only. Its last step, `seal()`, proves every leaf can be cleared: with all gates open it finds the cells a player can stand in, and any free cell with no standing spot within 2 m in a clear line (a slot behind a bench, say) is made solid, so neither leaves nor feet can get into it (5 cells with the present props; about 18 ms at load). **Leaves** are real objects, never removed by pointing: each has a place, a speed and a tumble, and leaves the garden only by being carried to a compost bin in the sack or by reaching a mulch chute. To stay cheap, resting leaves are asleep and cost nothing; each leaf sits in one grid cell (a linked list per cell), so a tool only visits the cells it reaches; and leaves do not collide one with another: a cell is a stack (each extra leaf rests 1.4 cm higher), a cell with 26 leaves turns sliding leaves away (40 for falling ones, about 56 cm) and a leaf near the top of a stack 5 taller than a neighbour slides off onto it. A leaf never moves more than 0.22 m in a step and its new place is rounded to what the arrays hold before the wall test, so nothing gets through or into a wall. That is what makes heaps against walls and rows in front of the rake. `Leaves.blow` is the blower (a cone; force falls with distance and with angle off the middle, 13 rays stop it at walls, leaves low in a heap are sheltered), `rake` carries the leaves under the head along with it, `scoop` sends the nearest leaves in a ring to the sack (they need a clear line from the player, except a garden's last 6 leaves, so none can be stranded behind a bench), `kick` is walking through them and `pull` the Draught grates reward. A leaf is two triangles: a flat card with one of four leaf shapes cut out of it (alpha test) by a 256 px atlas drawn in the page, tinted per leaf. They are drawn as instanced meshes, one per garden and leaf shape (20 draw calls); each mesh keeps its leaves in the order of the 4 m tile they started in and only the tiles where something moved are sent to the graphics card each frame. On top is one see-through 'litter' sheet whose opacity comes from a texture with one pixel per cell, so cleared ground looks clean about a second after its leaves go. **How many leaves** is the quality setting, in leaves per square metre of open ground (`WR.QUALITY`): Low 14 (27,600 leaves in the whole garden), Medium 24 (47,300), High 40 (78,800); Medium and High have a real shadow map from the low sun, drawn once (nothing that casts a shadow moves, except a gate opening), and Low has soft dark patches under the trees instead. Colours are written as screen colours and lit in linear light (`WR.lin`, sRGB output, ACES tone mapping), so any new colour or canvas texture must go through `WR.lin` or be marked sRGB. Phones start on Low, computers on Medium. Measured: with a fully upgraded blower sweeping through leaves the simulation costs 0.4 / 0.5 / 0.8 ms a step (1.4 / 3.0 / 2.8 ms at 4x CPU slowdown), with up to 2,800 leaves awake at once; looking across the first garden draws about 78k / 117k / 180k triangles in about 70 draw calls. Not measured: the cost of the cut-out leaves overlapping on a real phone's graphics chip (the test machines have none). `autores.js` lowers the resolution first; if frames stay slow for 8 s after that and the player never chose a setting, the game drops one leaf tier itself and says so. An area's leaves are worth the same in total at every tier (`units`; fewer leaves are each worth more), and the sack and the hands are measured in quality-free units too (an area's `leaves` number is its size in sack units; `Leaves.fill` is what one leaf takes), so progress and prices do not depend on the setting. Changing the setting scatters the leaves that are left again and keeps each garden's percent. **Looks and feedback.** `world.js` builds the house (door, lit windows, shutters, roof, chimney), trees with a crown of rounded masses shaded light above and dark below, walls with piers and caps, slatted benches, the fountain and a painted sky with cloud and a sun glow. `models.js` has rounded gloves on sleeves: open hands and the sack, a fist on the blower's handle, and two fists and forearms that follow the rake's handle in the garden itself. The blower shows wind streaks and lifts and tumbles leaves; landing from a jump throws leaves up and out, with a burst of loose leaves and a sound when it is a real heap; a rake stroke ends with a thump and a puff of crumbs; emptying the sack pours leaves into the bin; buying something pulses the HUD; 100% is a warm flash, falling leaves and a fanfare. **Tools and money.** Hands and sack, a rake (a stroke reaches out lifted, then drags back along the ground, so it pulls) and a blower (it pushes). Acorns come from leaves: at a bin when the sack is emptied (20% more for a full sack) or at once at a chute. `UP` in `game.js` is the shed (nine upgrades and their prices) and the arrays under it are what each level does; the models in `models.js` change with them. The leaf finder (F, or by itself when under 3% of a garden is left) lights the 8 nearest leaves of the garden you are standing in, and the journal map draws a dot for every leaf on the ground. **Saved data:** one localStorage key, `windrow:v1` (JSON): `acorns`, `earned`, `up` (upgrade levels), `unlocked` and `done` (per garden; six entries now, and a save with five is given the yard, open, as the sixth), `rewards`, `bagUnits` (what is in the sack, per garden) and `bagFill`, `gone` (share of each garden cleared), `tool`, `tut` (no longer used), `seen` (which instructions have been shown), `pos`, `secs`, `binFill`, `set` (look speed, volume, quality, flipped look, whether the player chose the quality), and `leaves` with `leafMul`: for each garden that has been touched, a base64 string of two 16-bit numbers a leaf (centimetres from the corner of the garden; 65535 = gone), about 250 KB at Medium and 420 KB at High once every garden has been disturbed; a leaf saved against a wall is stepped back out of it on loading. An untouched garden saves nothing and is scattered again from its seed. It saves 8 s after a change, on pause, and when the tab is hidden or closed. Keys are rebindable (`keybinds:windrow`); `autores.js` keeps its own scale. It is not in `account-nudge.js`'s KEYS, so it does not follow a Google account to another device, and it has no row in `leaderboard.js` or `miles.js`. **Touch:** `body.touch` is set on the first touch and shows `#touch` (left stick, Use, Jump, Run and Kneel once earned, a context button for bins and gates, and finder, journal and pause top right); the three tool slots at the bottom are tappable on any device. Portrait and landscape have their own positions in the style block; a drag on the view or on the Use button looks around. `WR.test` at the bottom of `game.js` is only for test scripts (start without a click, step the simulation, hold the tool, a simulation benchmark); nothing in the game calls it. - `e63334287a3deaa3/ebbwork/`: Flood Crew (Back Room; first built as Ebbwork, and the folder, the `ebbwork:v1` save key and the names in the code keep that name), a single-player first-person flood-drainage game: each job is a flooded place, and you work out why it flooded and get it dry (three.js r187 from the site's own build with its r128 layer, then `../autores.js`; no Firebase, no rooms, no stats.js, no ads). It is our own design: the name, the six places, the tools, the prices and the text are ours. **Files:** `index.html` (the page and its styles), `game.js` (drawing, controls, sound, HUD and menus), `core.js` (everything that is not drawing, with no DOM and no three.js in it, so `node` can load it: `require('./core.js')` gives `{EWSim, EW, EWMaps}`), `es.js` (its Spanish for `../lang.js`) and `preview.jpg`. **The water (`EWSim` in `core.js`):** a grid of 0.5 m cells, each with a ground height `g`, a barrier height `bar` laid on top, a depth `d` (kept in 64-bit numbers: with 32-bit ones a slow seep into a deep cell rounded away and volume drifted) and a flow through its right and bottom edge (`fx`, `fy`). Every step (1/30 s, fixed) each edge's flow speeds up by the difference in water surface across it and slows by friction (`fric`, `damp`), no cell may give more than it holds (flows out of a cell are scaled down together), and depths change by what flowed, so volume is conserved exactly: water only appears through `add()` and leaves through `take()`. Walls are `solid` cells. A 3 mm film (`FILM`) never flows, so floors keep real puddles in their dips. Blocks of 8 × 8 cells sleep when nothing in or next to them is changing; an edge into a sleeping block carries nothing and wakes it (leaving that out loses water across the edge). A big pool takes minutes to fall fully asleep because the film keeps creeping, so sleeping saves little while a map is draining; one step with every block awake costs about 1 ms for 128 × 128 cells on a desktop, and the biggest job is 68 × 48. **A job site (`EW.World`):** built from a map's `build(b)` with metres as the unit (x east, z south): `ground`, `shape` and `noise` set heights; `surf` sets the surface type and whether it can be dug; `wall` makes solid blocks (its `kind` is only for drawing); `drain` (a `rate` in m³/s and a `cap`: how much debris blocks it fully), `sinkArea` (water there leaves the map: a ditch or storm channel), `river` (cells held at a level: a stream that both feeds and takes water), `leak` (fed by a `valve` id, or `wrench: true` for a dripping joint), `valve`, `socket`, `litter`, `flood`, `spot` (a note the player gets when they walk near, kept in the journal), `sign`, `station` (the depot's board, bench and van) and `noJob` (cells that don't count). `step(dt)` runs leaks, the river, pumps, drains, sinks, the water and the debris, in that order. Debris floats in more than 5 cm of water, drifts with the current and towards a running drain, strands when the water drops, and blocks a drain by lying within 0.85 m of it (`clog`): a drain's rate is `rate × (0.03 + 0.97 × clear^1.6)`. The job is done (`isDone`) when the water left in the job's cells, not counting the film, is at most 3% of the most there has been (`World.DONE`) and nothing is still coming in. **Tools (each one a function on the world, so a test can call it):** `rake` (push or pull debris), `scoop` and `pour` (the 30-litre bucket), `squeegee` (moves water under 7 cm one cell along), `dig` and `pile` (soft ground only, down to `DIGMAX` 0.64 m; piling uses the spoil you dug), `placeBarrier` (three cells in a row, four directions, `BARH` 0.36 m; refused on drains, ditches and the river), `placePump` / `setHose` / `placeGen` (a pump runs when it is on, has a socket or a live generator within cable reach and has a hose end; water it takes goes to the hose end's cell, so emptying into the same pool does nothing, and it only leaves the map if the hose end is on a sink or the river; a generator standing in more than 14 cm of water stops), `takeDebris` (the sack: removes debris for good), `setValve` and `fixLeak`. **The jobs (`EWMaps`, in order; a job opens when the one before has a star):** Marlow Row (a back yard: a drain buried in leaves and a split pipe with its stop tap round the side; the first play walks a new player through it with `TUT`), Pell Street (three hidden drains, a dripping joint, a paving dip that keeps a puddle), Tanners Field (allotments in a hollow with no drain: a trench through the bank to the ditch; a choked pipe that sits too high to finish the job), Fenny Underpass (a dead sump: pump from a wall socket with the hose over the crest to the storm channel, and a water main valve at the far end), Wharf Cellar (the river seeps in through a doorway: sandbags, then pump up the steps; it is dark, so `sky: 'cellar'` gives a head torch) and Mill Lane (a stream through its bank, a culvert under a raft of debris, a walled garden that needs the pump and the generator, a hollow to trench). `EWMaps.depot` is the depot: not a job, a yard with the job board, the gear bench and the van, and a puddle to try tools on. Each map has `pay`, `par` (the target time in seconds) and `needs` (what the job board suggests bringing, shown only after the player has been there once, so the first visit is for finding out). Stars: one for finishing, a second inside 1.6 × `par`, a third inside `par` with 1.5% or less left; pay is `pay × (0.6 + 0.2 × stars)`, halved when the job has been done before. **Gear** (`GEAR` in the page): tools with `slot: 1` take one of the van's five places (seven with Van racking); the rest are upgrades (more sandbags, long hose, cable reel, second pump, waders, racking). Prices are set so that one-star pay alone affords each next job's tool. **Storage:** localStorage `ebbwork:v1` only: `{v, coins, gear, load, jobs: {: {stars, best, n, seen}}, set: {sens, vol, q, inv}, tut}`; keep `v: 1` and these names working if you change it. Nothing is sent anywhere. **Drawing:** the ground and the water are each one mesh with a vertex at every cell centre and their own shaders (`terrainMat`, `waterMat`): the water's vertices carry its depth and speed, a dry cell beside water takes its neighbours' surface height with a negative depth, and the shader throws away everything shallower than 4 mm, so the shoreline is a smooth line where the surface meets the ground and no squares show. Shallow water is see-through and deep water murky; ripples follow the flow; on High graphics the scene is drawn once more upside down into a small picture (`renderReflection`) so the water mirrors the buildings, and Low reflects the sky only. Graphics: Auto starts High on computers and Low on touch screens and Chromebooks, and steps down to Low for the rest of the visit if frames stay under about 34 a second for nine seconds, after `../autores.js` has had its chance to lower the resolution (`quality`, `autoLow`); it never steps back up by itself. Walls and props are two merged meshes (`Batch`: brickwork and plain), debris is three instanced meshes, and things the player puts down are rebuilt together when they change (`rebuildDyn`). **Sound** is all made in the page with the Web Audio API (`sfx`, `audioTick`): steps and wading, splashes, raking, digging, a gulp when a drain runs shallow, the pump's hum, and a lapping that fades as the place dries. **Touch:** a walk stick on the left (push it right out to run), drag anywhere else to look, and Use, Alt, Jump, Duck, Do and Turn buttons in `#touch`, shown only on touch screens; the tool bar moves to the top there. A slow frame is caught up rather than played in slow motion: up to a quarter of a second, as up to eight water steps and the walking split into 40 ms pieces. **Tests:** `window.__ew` (the world, the player, `start(id)`, `ff(seconds)` to run the water ahead, `use()`, `select()`) is for tests and tuning from the console. To check a changed map can still be finished, load `core.js` in node, build `new EW.World(map)` and call the tool functions and `step(1/30)` until `isDone()`; every job was checked that way when it was made. **To add a job:** push a map onto `MAPS` in `core.js` after the last one (ids are saved, so never rename or reorder them), give it `needs`, `pay` and `par`, put its Spanish in `es.js`, and finish it with a node script before trying it by hand. - `e63334287a3deaa3/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/es.js b/e63334287a3deaa3/es.js index 14a3dab2..8a75baf6 100644 --- a/e63334287a3deaa3/es.js +++ b/e63334287a3deaa3/es.js @@ -439,7 +439,7 @@ "Open Leaf Sweep": "Abrir Leaf Sweep", "More about Leaf Sweep": "Más sobre Leaf Sweep", "Garden sim": "Jardín", "New · Garden sim": "Nuevo · Simulador de jardín", "Relaxing": "Relajante", "Saves itself": "Se guarda solo", "Gather, rake and blow thousands of real leaves out of five walled gardens.": "Junta, rastrilla y sopla miles de hojas de verdad en cinco jardines amurallados.", - "Leaf Sweep in play, first person, in a walled brick courtyard under autumn trees: a rake with a wooden handle reaches out over grey paving that has just been cleared, with orange, gold and brown leaves and their litter still lying beyond it, a lawn square with a tree and a bench on the left, a stone fountain on the right and a green gate with a sign reading Orchard Walk, locked, 150. The acorn count and sack meter are top left, the garden name and percent cleared top centre, and the hands, rake and blower slots at the bottom.": "Leaf Sweep en juego, en primera persona, en un patio de ladrillo amurallado bajo árboles de otoño: un rastrillo con mango de madera se extiende sobre un pavimento gris recién limpiado, con hojas naranjas, doradas y marrones y sus restos más allá, un cuadro de césped con un árbol y un banco a la izquierda, una fuente de piedra a la derecha y un portón verde con un cartel que dice Orchard Walk, cerrado, 150. La cuenta de bellotas y el medidor del saco están arriba a la izquierda, el nombre del jardín y el porcentaje limpiado arriba al centro, y las casillas de manos, rastrillo y sopladora abajo.", + "Leaf Sweep in play, first person, in a small walled front yard under autumn trees: two gloved hands and a sack half full of leaves reach over a stone path that has just been cleared, with a thick carpet of orange, gold and brown leaves over the lawn on both sides, a brick wall with stone-capped piers, a green garden gate ahead with a bigger leaf-covered garden beyond it, and a slatted wooden compost bin on the right. The acorn count and sack meter are top left and a white ring on the path shows where the hands reach.": "Leaf Sweep en juego, en primera persona, en un pequeño jardín delantero amurallado bajo árboles de otoño: dos manos con guantes y un saco medio lleno de hojas se extienden sobre un camino de piedra recién limpiado, con una gruesa alfombra de hojas naranjas, doradas y marrones sobre el césped a ambos lados, un muro de ladrillo con pilares rematados en piedra, un portón verde al frente con un jardín más grande cubierto de hojas detrás y una compostera de madera a la derecha. La cuenta de bellotas y el medidor del saco están arriba a la izquierda y un aro blanco en el camino muestra hasta dónde llegan las manos.", "A calm first-person game about clearing autumn leaves. Every leaf is a real object: it slides, tumbles, lifts on the wind and heaps up against walls, and it only leaves the garden through a compost bin or a mulch chute. Earn acorns, buy better tools and open the next gate.": "Un juego tranquilo en primera persona sobre limpiar hojas de otoño. Cada hoja es un objeto de verdad: resbala, da vueltas, se levanta con el viento y se amontona contra los muros, y solo sale del jardín por una compostera o una rejilla de mantillo. Gana bellotas, compra mejores herramientas y abre el siguiente portón.", "Three tools: hands and a sack, a rake that drags rows of leaves toward you, and a blower that pushes them away in a cone of wind": "Tres herramientas: manos y un saco, un rastrillo que arrastra hileras de hojas hacia ti y una sopladora que las empuja con un cono de viento", "Five gardens (a paved court, an orchard, a decked lily terrace, a row of glasshouses and a hedge maze), each with its own percent cleared and a reward for finishing it": "Cinco jardines (un patio pavimentado, un huerto, una terraza de madera con nenúfares, una calle de invernaderos y un laberinto de setos), cada uno con su porcentaje limpiado y un premio por terminarlo", diff --git a/e63334287a3deaa3/index.html b/e63334287a3deaa3/index.html index c7b7fadc..aa3d1c32 100644 --- a/e63334287a3deaa3/index.html +++ b/e63334287a3deaa3/index.html @@ -1119,7 +1119,7 @@

Lanternhold

- Leaf Sweep in play, first person, in a walled brick courtyard under autumn trees: a rake with a wooden handle reaches out over grey paving that has just been cleared, with orange, gold and brown leaves and their litter still lying beyond it, a lawn square with a tree and a bench on the left, a stone fountain on the right and a green gate with a sign reading Orchard Walk, locked, 150. The acorn count and sack meter are top left, the garden name and percent cleared top centre, and the hands, rake and blower slots at the bottom. + Leaf Sweep in play, first person, in a small walled front yard under autumn trees: two gloved hands and a sack half full of leaves reach over a stone path that has just been cleared, with a thick carpet of orange, gold and brown leaves over the lawn on both sides, a brick wall with stone-capped piers, a green garden gate ahead with a bigger leaf-covered garden beyond it, and a slatted wooden compost bin on the right. The acorn count and sack meter are top left and a white ring on the path shows where the hands reach. NewGarden sim
diff --git a/e63334287a3deaa3/m/thumbs/windrow.jpg b/e63334287a3deaa3/m/thumbs/windrow.jpg index d85dbf9a..fc4c36ac 100644 Binary files a/e63334287a3deaa3/m/thumbs/windrow.jpg and b/e63334287a3deaa3/m/thumbs/windrow.jpg differ diff --git a/e63334287a3deaa3/news/ngcoding10-leaf-fix.json b/e63334287a3deaa3/news/ngcoding10-leaf-fix.json new file mode 100644 index 00000000..7d0ec74e --- /dev/null +++ b/e63334287a3deaa3/news/ngcoding10-leaf-fix.json @@ -0,0 +1,22 @@ +{ + "kind": "feature", + "title": "Leaf Sweep: a new start", + "tags": [ + "Leaf Sweep" + ], + "img": "m/thumbs/windrow.jpg", + "items": [ + "Leaf Sweep now starts in a small front yard by a garden house, with just your hands and one thing to do at a time.", + "Clear the yard and the gate to the big gardens opens. The rake arrives in the first couple of minutes.", + "New look: a house, fuller trees, soft shadows, a real sky, and gloves that actually hold the rake and blower.", + "Leaves fly in the blower's wind and burst when you jump into a heap. Your old progress is kept." + ], + "es": { + "Leaf Sweep: a new start": "Leaf Sweep: un nuevo comienzo", + "Leaf Sweep": "Leaf Sweep", + "Leaf Sweep now starts in a small front yard by a garden house, with just your hands and one thing to do at a time.": "Leaf Sweep ahora empieza en un pequeño jardín delantero junto a una casa, solo con tus manos y una cosa por hacer a la vez.", + "Clear the yard and the gate to the big gardens opens. The rake arrives in the first couple of minutes.": "Limpia el jardín y se abre el portón a los jardines grandes. El rastrillo llega en los primeros minutos.", + "New look: a house, fuller trees, soft shadows, a real sky, and gloves that actually hold the rake and blower.": "Nuevo aspecto: una casa, árboles más frondosos, sombras suaves, un cielo de verdad y guantes que realmente sostienen el rastrillo y la sopladora.", + "Leaves fly in the blower's wind and burst when you jump into a heap. Your old progress is kept.": "Las hojas vuelan con el viento de la sopladora y saltan cuando te lanzas a un montón. Tu progreso anterior se conserva." + } +} diff --git a/e63334287a3deaa3/windrow/es.js b/e63334287a3deaa3/windrow/es.js index 8a4a2b52..c0fa3c56 100644 --- a/e63334287a3deaa3/windrow/es.js +++ b/e63334287a3deaa3/windrow/es.js @@ -70,5 +70,18 @@ if (window.BackRoomLang) BackRoomLang.add({ // controls panel 'Move': 'Moverse', 'Work': 'Trabajar', 'Walk forward': 'Caminar adelante', 'Walk back': 'Caminar atrás', 'Step left': 'Paso a la izquierda', 'Step right': 'Paso a la derecha', 'Sprint': 'Correr', 'After you earn the running shoes': 'Cuando ganes las zapatillas para correr', 'After you earn the knee pads': 'Cuando ganes las rodilleras', - 'Empty sack or open a gate': 'Vaciar el saco o abrir un portón', 'Next tool': 'Siguiente herramienta' + 'Empty sack or open a gate': 'Vaciar el saco o abrir un portón', 'Next tool': 'Siguiente herramienta', + // the new start: one line of instruction at a time, and the Front Yard + 'Clear every last leaf.': 'Limpia hasta la última hoja.', 'Play': 'Jugar', 'Carry on': 'Continuar', 'Shed and map': 'Cobertizo y mapa', + 'Front Yard': 'Jardín Delantero', 'The garden gate': 'El portón del jardín', 'Gatehouse Court is open': 'El Patio de la Portería está abierto', + 'Hold Use to gather leaves': 'Mantén Usar para juntar hojas', 'Hold the left mouse button to gather leaves': 'Mantén el botón izquierdo del mouse para juntar hojas', + 'Your sack is full: empty it in the bin': 'Tu saco está lleno: vacíalo en la compostera', + 'Tap the shed button to spend your acorns': 'Toca el botón del cobertizo para gastar tus bellotas', 'Press {k} to spend your acorns in the shed': 'Pulsa {k} para gastar tus bellotas en el cobertizo', + 'You can afford the rake: tap the shed button': 'Ya te alcanza para el rastrillo: toca el botón del cobertizo', 'You can afford the rake: press {k}': 'Ya te alcanza para el rastrillo: pulsa {k}', + 'Bought the rake: hold to drag leaves into a pile': 'Compraste el rastrillo: mantén pulsado para juntar las hojas en un montón', + 'Bought the blower: hold to push leaves away': 'Compraste la sopladora: mantén pulsado para empujar las hojas', + '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.' }); diff --git a/e63334287a3deaa3/windrow/index.html b/e63334287a3deaa3/windrow/index.html index 2c0cc50e..a0310331 100644 --- a/e63334287a3deaa3/windrow/index.html +++ b/e63334287a3deaa3/windrow/index.html @@ -31,7 +31,7 @@ /* HUD */ #hud{position:absolute;inset:0;pointer-events:none} -.chip{display:flex;align-items:center;gap:7px;background:rgba(246,236,212,.92);border:1px solid var(--line);border-radius:999px;padding:5px 12px;font-size:16px;box-shadow:0 2px 8px rgba(0,0,0,.18)} +.chip{display:flex;align-items:center;gap:7px;background:rgba(246,236,212,.9);border:1px solid var(--line);border-radius:999px;padding:4px 11px;font-size:15px;box-shadow:0 1px 4px rgba(0,0,0,.14)} #hTop{position:absolute;left:calc(10px + var(--sl));top:calc(10px + var(--st));display:flex;flex-direction:column;gap:6px;align-items:flex-start} #hAcorns svg{width:18px;height:18px} #acN{min-width:2ch;font-variant-numeric:tabular-nums} @@ -47,8 +47,6 @@ #hArea .row{display:flex;align-items:center;gap:8px;width:100%} #hArea .meter{flex:1} #hArea .meter i{background:linear-gradient(90deg,var(--gold),var(--rust))} -#hKeys{position:absolute;right:calc(12px + var(--sr));top:calc(12px + var(--st));font-size:13px;color:#fff;text-shadow:0 1px 3px rgba(0,0,0,.7);text-align:right;line-height:1.5;opacity:.9} -#hKeys kbd{font:inherit;background:rgba(0,0,0,.35);border-radius:4px;padding:0 5px} #cross{position:absolute;left:50%;top:50%;width:6px;height:6px;margin:-3px;border-radius:50%;background:#fff;box-shadow:0 0 0 1.5px rgba(0,0,0,.45);opacity:.85} #hTools{position:absolute;left:50%;bottom:calc(12px + var(--sb));transform:translateX(-50%);display:flex;gap:8px;pointer-events:auto} .slot{position:relative;width:62px;height:54px;border-radius:12px;border:2px solid var(--line);background:rgba(246,236,212,.82);display:flex;flex-direction:column;align-items:center;justify-content:center;gap:1px;font-size:11px;letter-spacing:.04em;text-transform:uppercase;padding:0;color:var(--ink)} @@ -56,22 +54,32 @@ .slot kbd{position:absolute;left:5px;top:2px;font:inherit;font-size:11px;color:var(--ink-2)} .slot.on{background:var(--paper);border-color:var(--rust);box-shadow:0 0 0 2px rgba(196,85,45,.35),0 3px 10px rgba(0,0,0,.25);transform:translateY(-3px)} .slot.locked{opacity:.45} -#hPrompt{position:absolute;left:50%;top:60%;transform:translateX(-50%);background:rgba(30,24,14,.78);color:#fff;border-radius:10px;padding:7px 14px;font-size:16px;text-align:center;max-width:min(88vw,460px)} +/* the one line of instruction (#hint) and the thing you can do here (#hPrompt) share a place: bottom middle */ +#hPrompt,#hint{position:absolute;left:50%;bottom:calc(88px + var(--sb));transform:translateX(-50%);width:max-content;background:rgba(30,24,14,.72);color:#fff;border-radius:999px;padding:8px 18px;font-size:17px;text-align:center;max-width:min(88vw,520px);text-shadow:0 1px 2px rgba(0,0,0,.4)} +#hint.pulse{animation:hintIn .45s} +@keyframes hintIn{from{opacity:0;transform:translateX(-50%) translateY(8px)}} +#hShed{position:absolute;right:calc(12px + var(--sr));top:calc(12px + var(--st));font-size:14px;color:#fff;text-shadow:0 1px 3px rgba(0,0,0,.7);background:rgba(30,24,14,.45);border-radius:999px;padding:4px 12px} +#hShed kbd{font:inherit;background:var(--gold);color:var(--ink);border-radius:5px;padding:0 6px;margin-right:4px;text-shadow:none} +#flash{position:absolute;inset:0;pointer-events:none;opacity:0;background:radial-gradient(ellipse at 50% 60%,rgba(255,226,140,.0) 30%,rgba(255,210,90,.55) 100%)} +#flash.on{animation:flash 1.8s ease-out} +@keyframes flash{0%{opacity:0}12%{opacity:1}100%{opacity:0}} +.pulse{animation:pulse .5s} +@keyframes pulse{35%{transform:scale(1.12)}} +#hBag.shake{animation:shake .4s} +@keyframes shake{20%,60%{transform:translateX(-5px)}40%,80%{transform:translateX(5px)}} #hPrompt kbd{font:inherit;background:var(--gold);color:var(--ink);border-radius:5px;padding:0 7px;margin-right:4px} -#toasts{position:absolute;left:50%;top:22%;transform:translateX(-50%);display:flex;flex-direction:column;gap:6px;align-items:center;width:min(92vw,520px)} +#toasts{position:absolute;left:50%;top:16%;transform:translateX(-50%);display:flex;flex-direction:column;gap:6px;align-items:center;width:min(92vw,520px)} .toast{background:var(--paper);border:1px solid var(--line);border-left:5px solid var(--rust);border-radius:10px;padding:8px 14px;font-size:16px;box-shadow:0 6px 18px rgba(0,0,0,.25);animation:rise .3s;text-align:center} .toast.big{font-family:var(--f-d);font-size:22px;border-left-color:var(--gold);padding:12px 18px} .toast small{display:block;font-family:var(--f-b);font-size:14px;color:var(--ink-2);font-weight:700} @keyframes rise{from{opacity:0;transform:translateY(10px)}} -#hTut{position:absolute;left:50%;top:calc(74px + var(--st));transform:translateX(-50%);width:max-content;background:rgba(44,74,58,.92);color:#fff;border-radius:12px;padding:8px 14px;font-size:15px;max-width:min(90vw,440px);text-align:center;pointer-events:auto;display:flex;gap:10px;align-items:center} -#hTut button{background:none;border:1px solid rgba(255,255,255,.4);border-radius:8px;color:#fff;font-size:12px;padding:3px 8px;flex:none} -#gain{position:absolute;left:calc(14px + var(--sl));top:calc(88px + var(--st));font-size:15px;color:#fff;text-shadow:0 1px 3px rgba(0,0,0,.8);opacity:0;transition:opacity .4s} +#gain{position:absolute;left:calc(104px + var(--sl));top:calc(15px + var(--st));font-weight:800;font-size:15px;color:#fff;text-shadow:0 1px 3px rgba(0,0,0,.8);opacity:0;transition:opacity .4s} #gain.on{opacity:1} /* touch controls: hidden until a finger touches the screen */ #touch{display:none;position:absolute;inset:0;pointer-events:none} body.touch #touch{display:block} -body.touch #hKeys,body.touch .slot kbd,body.touch .kbonly{display:none} +body.touch .slot kbd,body.touch .kbonly{display:none} #tStick{position:absolute;left:calc(22px + var(--sl));bottom:calc(26px + var(--sb));width:124px;height:124px;border-radius:50%;background:rgba(246,236,212,.2);border:2px solid rgba(255,255,255,.45);pointer-events:auto;touch-action:none} #tStick i{position:absolute;left:50%;top:50%;width:52px;height:52px;margin:-26px;border-radius:50%;background:rgba(246,236,212,.85);box-shadow:0 2px 8px rgba(0,0,0,.3)} .tb{position:absolute;pointer-events:auto;touch-action:none;border-radius:50%;border:2px solid rgba(255,255,255,.55);background:rgba(30,24,14,.5);color:#fff;font-size:12px;letter-spacing:.05em;display:flex;align-items:center;justify-content:center;padding:0;text-transform:uppercase} @@ -80,7 +88,7 @@ #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} -#tAct{left:50%;top:60%;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} +#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} #tTop svg{width:22px;height:22px} @@ -90,9 +98,9 @@ @media (orientation:portrait){ body.touch #hTools{bottom:calc(172px + var(--sb))} body.touch #hArea{top:calc(96px + var(--st))} - body.touch #hTut{top:calc(164px + var(--st))} body.touch #toasts{top:34%} - body.touch #gain{top:calc(92px + var(--st));left:auto;right:calc(14px + var(--sr))} + body.touch #hint,body.touch #hPrompt{bottom:calc(238px + var(--sb))} + body.touch #tAct{bottom:calc(234px + var(--sb))} } @media (orientation:landscape) and (max-height:480px){ #hArea{padding:4px 12px 5px;min-width:170px}#hArea b{font-size:15px} @@ -103,9 +111,9 @@ body.touch #tKneel{right:calc(26px + var(--sr));bottom:calc(106px + var(--sb));width:48px;height:48px} 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} - #hTut{top:calc(68px + var(--st));font-size:13px;padding:5px 10px} - #hPrompt,#tAct{top:52%} - #toasts{top:30%} + #hPrompt,#hint{bottom:calc(64px + var(--sb));font-size:15px;padding:6px 14px;max-width:46vw} + #tAct{bottom:calc(62px + var(--sb))} + #toasts{top:20%} } /* menus */ @@ -124,12 +132,16 @@ .btn:active:not(:disabled){transform:scale(.97)} .btn.go{background:var(--green);border-color:var(--green-2);color:#fff;font-size:20px;padding:12px 18px} .btn.sm{font-size:14px;padding:6px 11px;border-radius:9px} +#title .card{width:min(380px,100%)}.btn.ghost{background:none;border-color:transparent;color:var(--ink-2);align-self:center} +.tabs{align-items:center}.tabs h2{font-size:22px;margin-right:6px} .btn.buy{background:var(--gold);border-color:#b98e1e;min-width:84px} .btn:disabled{opacity:.5;cursor:default} .head{display:flex;align-items:center;justify-content:space-between;gap:10px;margin-bottom:10px} .tabs{display:flex;gap:6px} .tabs .btn.on{background:var(--green);color:#fff;border-color:var(--green-2)} #jBody{display:grid;grid-template-columns:minmax(0,1.15fr) minmax(0,1fr);gap:14px} +#jBody.solo{display:block}#jBody.solo #map{display:none} +.card.wide:has(#jBody.solo){width:min(520px,100%)} #map{width:100%;height:auto;border-radius:10px;border:1px solid var(--line);background:#cfc3a2;display:block} #jSide{max-height:min(62vh,520px);overflow:auto;-webkit-overflow-scrolling:touch;touch-action:pan-y;padding-right:2px} .item{display:flex;align-items:center;gap:10px;padding:8px 0;border-bottom:1px dashed var(--line)} @@ -164,10 +176,11 @@
Sack
0/30
0%
-
+ +
- +
@@ -193,13 +206,11 @@

Leaf Sweep

-

The old gardens are buried in autumn. Gather, rake and blow every last leaf away, one walled garden at a time.

+

Clear every last leaf.

- - - + +
-

Your garden saves itself in this browser.

@@ -208,7 +219,7 @@

Leaf Sweep

Paused

- + @@ -219,14 +230,14 @@

Paused

diff --git a/e63334287a3deaa3/windrow/js/audio.js b/e63334287a3deaa3/windrow/js/audio.js index 8ff453bc..57ed9aea 100644 --- a/e63334287a3deaa3/windrow/js/audio.js +++ b/e63334287a3deaa3/windrow/js/audio.js @@ -54,4 +54,6 @@ 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.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 ce7f7915..6c8e6f7f 100644 --- a/e63334287a3deaa3/windrow/js/game.js +++ b/e63334287a3deaa3/windrow/js/game.js @@ -11,9 +11,9 @@ /* ---------- 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: [30, 90, 220, 520] }, - { id: 'rake', name: 'Rake', text: 'Drags a whole row of leaves toward you with every stroke', costs: [60] }, + { id: 'sack', name: 'Bigger sack', text: 'Carry more leaves before a trip to the bin', costs: [35, 110, 260, 600, 1300] }, + { id: 'hands', name: 'Quick hands', text: 'Gather faster and reach wider', costs: [15, 60, 180, 480] }, + { id: 'rake', name: 'Rake', text: 'Drags a whole row of leaves toward you with every stroke', costs: [40] }, { 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' }, @@ -29,11 +29,14 @@ /* ---------- 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 }, - unlocked: [1, 0, 0, 0, 0], done: [0, 0, 0, 0, 0], rewards: {}, bagUnits: [0, 0, 0, 0, 0], bagFill: 0, gone: [0, 0, 0, 0, 0], tool: 0, tut: 0, pos: null, + 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) {} + // 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 }; 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; @@ -46,8 +49,10 @@ } /* ---------- scene ---------- */ - var canvas = $('view'), renderer = new THREE.WebGLRenderer({ canvas: canvas, antialias: !touchDev, powerPreference: 'high-performance' }); + var canvas = $('view'), renderer = new THREE.WebGLRenderer({ canvas: canvas, antialias: true, powerPreference: 'high-performance' }); renderer.autoClear = false; renderer.shadowMap.enabled = true; renderer.shadowMap.type = THREE.PCFSoftShadowMap; + // 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'; WR.buildGrid(state.unlocked); var world = WR.buildWorld(scene), vm = WR.buildViewModels(scene, state), fx = new WR.Fx(scene, 90), leaves = null; @@ -60,12 +65,13 @@ function onGone(ar, w, how, idx) { dirty = true; if (how === 'bag') { state.bagUnits[ar] += w; state.bagFill += leaves.fill[ar]; Au.pick(); bagDirty = true; } - else { pay(w, 1); Au.chute(); var c = WR.CHUTES[idx]; if (Math.random() < .3) fx.spawn(c.x + (Math.random() - .5), .1, c.z + (Math.random() - .5), 0, 1.2, 0, .5, A[ar].pal[0], .16); if (state.tut === 4) tutNext(5); } + else { pay(w, 1); Au.chute(); var c = WR.CHUTES[idx]; if (Math.random() < .3) fx.spawn(c.x + (Math.random() - .5), .1, c.z + (Math.random() - .5), 0, 1.2, 0, .5, A[ar].pal[0], .16); } } function applyQuality() { var q = state.set.q; renderer.setPixelRatio(Math.min(window.devicePixelRatio || 1, q === 'high' ? 2 : q === 'medium' || touchDev ? 1.5 : 1)); - world.sun.castShadow = q === 'high'; world.blobs.visible = q !== 'high'; world.sun.shadow.needsUpdate = true; + // nothing that casts a shadow moves, so the shadow map is drawn once and costs almost nothing after that: Medium gets it too + world.sun.castShadow = q !== 'low'; world.blobs.visible = q === 'low'; world.sun.shadow.needsUpdate = true; if (leaves) { state.gone = A.map(function (a, i) { return leaves.share(i); }); leaves.dispose(); state.leaves = null; } leaves = WR.leaves = new WR.Leaves(scene, state, WR.QUALITY[q]); leaves.onGone = onGone; needRender = true; } @@ -85,7 +91,7 @@ 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; function playing() { return inGame && !ov.length; } - function setTouch() { if (touchUI) return; touchUI = true; document.body.classList.add('touch'); $('howTouch').hidden = false; hudStatic(); } + function setTouch() { if (touchUI) return; touchUI = true; document.body.classList.add('touch'); $('howTouch').hidden = false; hudStatic(); hudT = 0; } addEventListener('touchstart', setTouch, { passive: true }); addEventListener('contextmenu', function (e) { if (inGame) e.preventDefault(); }); addEventListener('keydown', function (e) { @@ -165,18 +171,19 @@ var sy = Math.sin(p.yaw), cy = Math.cos(p.yaw), tx = (-sy * f + cy * s) * sp, tz = (-cy * f - sy * s) * sp, k = Math.min(1, dt * (p.ground ? 12 : 3)); p.vx += (tx - p.vx) * k; p.vz += (tz - p.vz) * k; var ox = p.x, oz = p.z; p.x += p.vx * dt; p.z += p.vz * dt; WR.collide(p, 0.34); - if (!p.ground) { p.vy -= 13 * dt; p.y += p.vy * dt; if (p.y <= 0) { p.y = 0; p.vy = 0; p.ground = true; Au.step(WR.gtype[WR.cellOf(p.x, p.z)] === 2); leaves.kick(p.x, p.z, 0.7, 0, 0); } } + if (!p.ground) { p.vy -= 13 * dt; var fallV = -p.vy; p.y += p.vy * dt; if (p.y <= 0) { p.y = 0; p.vy = 0; p.ground = true; Au.step(WR.gtype[WR.cellOf(p.x, p.z)] === 2); + // landing in leaves throws them up and out; a real heap makes a proper burst + var deep = leaves.countIn(p.x, p.z, 0.8), hard = Math.min(1, fallV / 5); leaves.burst(p.x, p.z, 1.15, 0.6 + hard * 1.2 + Math.min(1.4, deep / 60)); + if (deep > 20) { Au.burst(Math.min(1, deep / 90)); for (var bq = 0; bq < Math.min(14, deep / 6); bq++) fx.spawn(p.x + (Math.random() - .5) * .8, .2, p.z + (Math.random() - .5) * .8, (Math.random() - .5) * 3, 2 + Math.random() * 2.5, (Math.random() - .5) * 3, 1.3, A[curArea].pal[bq % 5], .24, 0.02); } } } var moved = Math.hypot(p.x - ox, p.z - oz); speedNow = moved / Math.max(dt, 1e-4); if (p.ground && moved > 0.001) { p.stepD += moved; p.bob += moved * 3.3; if (p.stepD > (sprint ? 2.6 : 2.0)) { p.stepD = 0; Au.step(WR.gtype[WR.cellOf(p.x, p.z)] === 2); } if (speedNow > 0.8) leaves.kick(p.x, p.z, 0.42, p.vx, p.vz); - if (state.tut === 0) { tutMove += moved; if (tutMove > 4) tutNext(1); } } var eyeT = kneeling ? 0.95 : 1.62; p.eye += (eyeT - p.eye) * Math.min(1, dt * 9); camera.position.set(p.x, p.y + p.eye + Math.sin(p.bob) * 0.022 * Math.min(1, speedNow / 3), p.z); camera.rotation.set(p.pitch, p.yaw, 0); } - var tutMove = 0; /* ---------- tools ---------- */ var tool = state.tool || 0, toolT = 0, rakeT = 0, rakeHead = { x: 0, z: 0, has: false }, handAcc = 0, handAnim = 0, blowAnim = 0, scraping = false, blowing = false, fullT = 0, bagDirty = true; @@ -189,7 +196,8 @@ camera.getWorldDirection(fwd); var sy = Math.sin(p.yaw), cy = Math.cos(p.yaw), fx2 = -sy, fz2 = -cy, rx = cy, rz = -sy, cap = SACK[state.up.sack]; bagPos.set(p.x - rx * 0.3 + fx2 * 0.3, p.y + p.eye - 0.5, p.z - rz * 0.3 + fz2 * 0.3); - vm.hands.visible = tool === 0; vm.blower.visible = tool === 2; vm.rake.visible = vm.handle.visible = tool === 1; vm.ring.visible = false; vm.air.visible = false; + vm.hands.visible = tool === 0; vm.blower.visible = tool === 2; vm.ring.visible = false; vm.air.visible = false; + 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 @@ -199,15 +207,16 @@ vm.ring.visible = true; vm.ring.position.set(tx, 0.035, tz); vm.ring.scale.setScalar(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; toast(T('Sack full. Empty it at a bin with a red flag')); Au.full(); } } + if (room <= 0) { fullT -= dt; if (fullT <= 0) { fullT = 2.5; 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; tutPicked += took * per; if (state.tut === 1 && tutPicked >= 12) tutNext(2); } } + 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) { grabbed += took; if (grabbed >= 25) { state.seen.grab = 1; hudT = 0; } } } } } } else handAcc = 0; handAnim = Math.max(0, handAnim - dt * 3); var sw = using ? Math.sin(toolT * 13) : 0; - vm.rh.position.set(0.25 - handAnim * 0.06, -0.2 - (using ? 0.05 : 0) + sw * 0.03 + (raise - 1) * 0.3, -0.5 - (using ? 0.12 : 0) - sw * 0.04); + 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; } else if (tool === 1) { // a stroke: reach out with the head lifted, drop it, drag it back along the ground @@ -218,28 +227,32 @@ var hx = p.x + fx2 * dist, hz = p.z + fz2 * dist; if (pulling && rakeHead.has && dt > 0) { var hvx = (hx - rakeHead.x) / dt, hvz = (hz - rakeHead.z) / dt, hs = Math.hypot(hvx, hvz); if (hs > 9) { hvx *= 9 / hs; hvz *= 9 / hs; } - var hit = leaves.rake(hx - rx * W / 2, hz - rz * W / 2, hx + rx * W / 2, hz + rz * W / 2, 0.24, hvx, hvz); scraping = hit > 0; + var hit = leaves.rake(hx - rx * W / 2, hz - rz * W / 2, hx + rx * W / 2, hz + rz * W / 2, 0.24, hvx, hvz); scraping = hit > 0; strokeHits += hit; } + // the end of a stroke: a soft thump and a puff of crumbs where the leaves were left + if (rakeHead.has && !pulling) { if (strokeHits > 3) { Au.thud(Math.min(1, strokeHits / 400)); for (var cq = 0; cq < Math.min(8, 2 + strokeHits / 60); cq++) fx.spawn(rakeHead.x + rx * (Math.random() - .5) * W, .1, rakeHead.z + rz * (Math.random() - .5) * W, (Math.random() - .5) * 1.2, 1 + Math.random() * 1.2, (Math.random() - .5) * 1.2, .7, A[curArea].pal[cq % 5], .16, 0.02); raked += strokeHits; } strokeHits = 0; } rakeHead.x = hx; rakeHead.z = hz; rakeHead.has = pulling; vm.rake.position.set(hx, lift, hz); vm.rake.rotation.y = p.yaw; tmp.set(p.x + rx * 0.26 + fx2 * 0.2, p.y + p.eye - 0.42 - (1 - raise) * 0.4, p.z + rz * 0.26 + fz2 * 0.2); tmp2.set(hx, lift + 0.16, hz); - vm.handle.position.copy(tmp); vm.handle.lookAt(tmp2); vm.handle.scale.z = tmp.distanceTo(tmp2); + vm.rake.rotation.x = using && !pulling ? -0.25 : 0; vm.poseRake(tmp, tmp2, camera.position, rx, rz, true); } else { - var lv = state.up.nozzle, range = BLOW_R[lv], half = BLOW_H[lv]; + var lv = state.up.nozzle, range = BLOW_R[lv], half = BLOW_H[lv], windOn = false; if (using) { blowing = true; var dy = Math.max(-0.5, Math.min(0.12, fwd.y)), hl = Math.hypot(fwd.x, fwd.z) || 1, k = Math.sqrt(1 - dy * dy), dx = fwd.x / hl * k, dz = fwd.z / hl * k; var ox = p.x + fx2 * 0.35, oz = p.z + fz2 * 0.35, oy = 0.42; leaves.blow(ox, oy, oz, dx, dy * 0.5, dz, range, half, BLOW_P[state.up.power], dt); vm.air.visible = true; vm.air.position.set(ox + rx * 0.2, p.y + p.eye - 0.5, oz + rz * 0.2); tmp.set(ox + dx * range, 0.3, oz + dz * range); vm.air.lookAt(tmp); var rad = Math.tan(half) * range; vm.air.scale.set(rad, rad * 0.5, range); vm.air.material.opacity = 0.05 + 0.03 * Math.sin(toolT * 40); - if (state.tut === 4) tutBlow += dt; + vm.wind(dt, true, ox + rx * 0.2, 0.5, oz + rz * 0.2, dx, dy * 0.5, dz, range, half); windOn = true; } + if (!windOn) vm.wind(dt, false); blowAnim += ((using ? 1 : 0) - blowAnim) * Math.min(1, dt * 10); - vm.blower.position.set(0.3 + Math.sin(toolT * 47) * 0.004 * blowAnim, -0.3 + (raise - 1) * 0.3 + Math.sin(toolT * 61) * 0.004 * blowAnim, -0.42 + blowAnim * 0.02); + vm.blower.position.set(0.2 + Math.sin(toolT * 47) * 0.004 * blowAnim, -0.27 + (raise - 1) * 0.3 + Math.sin(toolT * 61) * 0.004 * blowAnim, -0.52 + blowAnim * 0.02); } + if (tool !== 2) vm.wind(dt, false); vm.hands.position.y = tool === 0 ? Math.sin(p.bob) * 0.008 : 0; } - var tutPicked = 0, tutBlow = 0; + var grabbed = 0, raked = 0, strokeHits = 0; /* ---------- bins, gates, money ---------- */ var gainAcc = 0, gainT = 0, prompt = null; @@ -248,7 +261,8 @@ 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 > 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 (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; + 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) }) } : state.acorns < a.cost ? { type: 'gate', d: d, ok: false, text: T('{a}: opens for {n} acorns', { a: T(a.name), n: a.cost }) } @@ -261,44 +275,50 @@ } function emptyBag(bi) { var units = 0, cap = SACK[state.up.sack], full = state.bagFill >= cap * 0.95, b = WR.BINS[bi]; - for (var i = 0; i < 5; i++) { units += state.bagUnits[i]; state.bagUnits[i] = 0; } + for (var i = 0; i < A.length; i++) { units += state.bagUnits[i]; state.bagUnits[i] = 0; } var n = Math.min(40, Math.round(state.bagFill / 3) + 6); - for (i = 0; i < n; i++) fx.spawn(b.x + (Math.random() - .5) * .8, 1.5 + Math.random() * .8, b.z + (Math.random() - .5) * .8, (Math.random() - .5), -0.5 - Math.random(), (Math.random() - .5), 1.1 + Math.random() * .5, A[(Math.random() * 5) | 0].pal[(Math.random() * 5) | 0], .22, 0.5); + for (i = 0; i < n; i++) fx.spawn(b.x + (Math.random() - .5) * .8, 1.5 + Math.random() * .8, b.z + (Math.random() - .5) * .8, (Math.random() - .5), -0.5 - Math.random(), (Math.random() - .5), 1.1 + Math.random() * .5, A[curArea].pal[(Math.random() * 5) | 0], .22, 0.5); state.binFill = Math.min(1, (state.binFill || 0) + state.bagFill / 2500); world.bins.forEach(function (B) { B.heap.scale.y = 0.3 + state.binFill * 0.9; }); state.bagFill = 0; bagDirty = true; var amt = pay(units, full ? 1.2 : 1); Au.bin(); Au.coin(); toast(T('+{n} acorns', { n: Math.round(amt) }) + (full ? ' · ' + T('full sack bonus') : '')); - if (state.tut === 2) tutNext(3); + state.seen.bin = 1; hudStatic(); hudT = 0; vm.refresh(); checkDone(); save(); } 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); - Au.gate(); Au.buy(); toast(T('{a} is open', { a: T(a.name) }), true); acDirty = true; save(); return true; + Au.gate(); Au.buy(); toast(T('{a} is open', { a: T(a.name) }), true); acDirty = true; hudStatic(); save(); return true; } function buy(id) { var u = UP.filter(function (x) { return x.id === id; })[0], lv = state.up[id]; if (!u || lv >= u.costs.length) return; 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(); - if (id === 'rake') { tool = state.tool = 1; toolT = 0; toast(T('Rake bought. Hold to pull leaves toward you')); } if (id === 'blower') { tool = state.tool = 2; toolT = 0; toast(T('Blower bought. Hold to push leaves away')); } - hudStatic(); - if (state.tut === 3) tutNext(4); + 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) + ' ✓'); + hudStatic(); pulse(id === 'sack' || id === 'hands' ? 'hBag' : 'hTools'); save(); renderJournal(); } function checkDone() { - for (var i = 0; i < 5; i++) { + for (var i = 0; i < A.length; i++) { if (!state.unlocked[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); } 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(); - for (var k = 0; k < 40; k++) fx.spawn(p.x + (Math.random() - .5) * 5, 2.5 + Math.random() * 2, p.z + (Math.random() - .5) * 5, 0, 0, 0, 3, a.pal[k % 5], .26, 0.02); + Au.fanfare(); vm.refresh(); hudStatic(); save(); celebrate(a); } } + // 100%: a warm flash over the screen and leaves raining down all round + function celebrate(a) { + var f = $('flash'); f.classList.remove('on'); void f.offsetWidth; f.classList.add('on'); + for (var k = 0; k < 70; k++) fx.spawn(p.x + (Math.random() - .5) * 7, 2.2 + Math.random() * 2.6, p.z + (Math.random() - .5) * 7, (Math.random() - .5) * 1.5, 1 + Math.random() * 2, (Math.random() - .5) * 1.5, 2.6, ['#ffd24a', '#fff1c4'].concat(a.pal)[k % 7], .26); + } function rewardText(a) { if (touchUI) { if (a.reward === 'sprint') return 'Tap Run to sprint'; if (a.reward === 'crouch') return 'Tap Kneel: hands gather twice as fast'; } return a.rewardText; } /* ---------- leaf finder ---------- */ - var finder = false, findT = 0, near = [], curArea = 0; + var finder = false, findT = 0, near = [], curArea = Math.max(0, WR.areaOf[WR.cellOf(p.x, p.z)]); 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; @@ -307,22 +327,46 @@ 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; } } - /* ---------- HUD ---------- */ - var hudT = 0; - function toast(html, big, secs) { var d = document.createElement('div'); d.className = 'toast' + (big ? ' big' : ''); d.setAttribute('data-noi18n', ''); d.innerHTML = html; var box = $('toasts'); while (box.children.length > 2) box.removeChild(box.firstChild); box.appendChild(d); setTimeout(function () { if (d.parentNode) d.parentNode.removeChild(d); }, (secs || (big ? 4.5 : 2.6)) * 1000); } + /* ---------- HUD ---------- + A new player sees a crosshair, the sack and the acorns, and one short line of instruction at the bottom. The rest + arrives when it first matters: percent cleared after the first bin, the shed after the first acorns, the tool bar + with a second tool, garden names, the map, gate signs and the finder once the first gate has opened. */ + var hudT = 0, sayTxt = null, sayT = 0, markT = 0; + function toast(html, big, secs) { var d = document.createElement('div'); d.className = 'toast' + (big ? ' big' : ''); d.setAttribute('data-noi18n', ''); d.innerHTML = html; var box = $('toasts'); while (box.children.length > 1) box.removeChild(box.firstChild); box.appendChild(d); setTimeout(function () { if (d.parentNode) d.parentNode.removeChild(d); }, (secs || (big ? 4.5 : 2.2)) * 1000); } + function say(text, secs) { sayTxt = text; sayT = secs || 8; hudT = 0; } + function pulse(id) { var el = $(id); if (!el) return; el.classList.remove('pulse'); void el.offsetWidth; el.classList.add('pulse'); } + function shedOpen() { return state.earned > 0; } + function shedKey() { return KB.short('journal'); } function hudStatic() { - Array.prototype.forEach.call(document.querySelectorAll('.slot'), function (b) { var t = +b.dataset.tool; b.classList.toggle('on', t === tool); b.classList.toggle('locked', !owns(t)); }); - $('hKeys').innerHTML = '' + KB.short('journal') + ' ' + T('Journal') + '
' + KB.short('find') + ' ' + T('Leaf finder') + '
Esc ' + T('Pause'); + var tools = !!(state.up.rake || state.up.blower); + $('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; - $('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 journal.', { m: KB.label(['fwd', 'left', 'back', 'right'], ' ', '', 1), j: KB.short('jump'), a: '1 2 3', e: KB.short('use'), t: KB.short('journal') }); - tutShow(); + $('hShed').hidden = $('tJournal').hidden = !shedOpen(); $('hShedKey').textContent = shedKey(); + $('tFind').hidden = !state.unlocked[0]; + $('hArea').hidden = !shedOpen(); $('arName').hidden = !state.unlocked[0]; + $('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') }); } KB.onChange(hudStatic); + // the one line at the bottom: what to do right now, or nothing + function hintText() { + 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 (!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() }); + return null; + } function hud(dt) { - hudT -= dt; gainT -= 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.999); 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.round(state.bagFill)) + '/' + 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; } if (hudT > 0) return; hudT = 0.2; var c = WR.areaOf[WR.cellOf(p.x, p.z)]; if (c >= 0) curArea = c; var sh = leaves.share(curArea), left = leaves.alive[curArea]; @@ -330,26 +374,14 @@ var al = $('arLeft'), show = !state.done[curArea] && left <= 60; 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'); - 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; } - else { hp.hidden = true; ta.hidden = true; } + 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; } + 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; + if (!state.seen.chute && state.unlocked[0] && (state.up.rake || state.up.blower)) WR.CHUTES.forEach(function (ch) { if (!state.seen.chute && Math.hypot(ch.x - p.x, ch.z - p.z) < 5) { state.seen.chute = 1; say(T('Leaves that reach a yellow grate are paid at once'), 9); } }); checkDone(); - if (state.tut === 4 && tutBlow > 1.5) tutNext(5); - } - /* ---------- tutorial ---------- */ - function tutText() { - var t = touchUI; - return [ - t ? 'Left thumb walks. Drag anywhere else to look around.' : T('Click to look around. Walk with {k}.', { k: KB.label(['fwd', 'left', 'back', 'right'], ' ', '', 1) }), - t ? 'Look down at some leaves and hold Use to gather them into your sack.' : 'Look down at some leaves and hold the left mouse button to gather them into your sack.', - t ? 'Carry them to the compost bin with the red flag and tap Empty your sack.' : T('Carry them to the compost bin with the red flag and press {k}.', { k: KB.short('use') }), - t ? 'Tap the book, open the Shed and buy something with your acorns.' : T('Press {k}, open the Shed and buy something with your acorns.', { k: KB.short('journal') }), - 'Leaves that reach a yellow grate are paid for at once. Rake or blow them onto it.' - ][state.tut]; } - function tutShow() { var s = tutText(); $('hTut').hidden = !s; if (s) $('tutText').textContent = T(s); } - function tutNext(n) { if (state.tut >= n) return; state.tut = n; dirty = true; tutShow(); if (n < 5) Au.click(); } - $('tutSkip').addEventListener('click', function () { tutNext(5); }); /* ---------- menus ---------- */ function showOv() { ['title', 'pause', 'journal', 'settings', 'how'].forEach(function (id) { $(id).hidden = ov[ov.length - 1] !== id; }); $('hud').hidden = !inGame || ov.length > 0; } @@ -367,12 +399,12 @@ 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(); }); $('resumeBtn').addEventListener('click', function () { closeTop(); }); - $('howBtn').addEventListener('click', function () { open('how'); }); $('pHow').addEventListener('click', function () { open('how'); }); + $('pHow').addEventListener('click', function () { open('how'); }); $('setBtn').addEventListener('click', function () { open('settings'); }); $('pSet').addEventListener('click', function () { open('settings'); }); $('pJournal').addEventListener('click', function () { open('journal'); }); $('pTitle').addEventListener('click', function () { save(); inGame = false; ov = ['title']; showOv(); titleText(); }); $('jClose').addEventListener('click', closeTop); $('sClose').addEventListener('click', closeTop); $('hClose').addEventListener('click', closeTop); - function titleText() { $('playBtn').textContent = T(state.earned > 0 || state.tut > 0 ? 'Carry on sweeping' : 'Start sweeping'); } + function titleText() { $('playBtn').textContent = T(state.earned > 0 ? 'Carry on' : 'Play'); } // settings function fillSettings() { $('sSens').value = state.set.sens; $('sVol').value = state.set.vol; $('sQ').value = state.set.q; $('sInv').checked = !!state.set.inv; } $('sSens').addEventListener('input', function () { state.set.sens = +this.value; dirty = true; }); @@ -388,17 +420,21 @@ location.reload(); }); // journal: the map, the gardens and the shed - var tab = 'areas'; + 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; } 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; - Array.prototype.forEach.call(document.querySelectorAll('.tabs .btn'), function (b) { b.classList.toggle('on', b.dataset.tab === tab); }); + var maps = !!state.unlocked[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'); var h = '', side = $('jSide'); side.setAttribute('data-noi18n', ''); if (tab === 'areas') { - A.forEach(function (a, i) { - var sh = leaves.share(i), un = state.unlocked[i], need = a.need && leaves.share(a.need[0]) < a.need[1]; + WR.ORDER.forEach(function (i) { + var a = A[i], sh = leaves.share(i), un = state.unlocked[i], need = a.need && leaves.share(a.need[0]) < a.need[1]; h += '
' + T(a.name) + (un ? ' · ' + (sh >= 1 ? 100 : Math.floor(sh * 100)) + '%' : '') + ''; if (state.done[i]) h += '✓ ' + T('Clear') + ' · ' + T(a.rewardName) + ''; else if (un) h += '' + T('Clear it all: +{n} acorns and {r}', { n: a.bonus, r: T(a.rewardName) }) + ''; @@ -406,7 +442,8 @@ h += '
' + (un ? '' : '') + '
'; }); } else { - UP.forEach(function (u) { + // cheapest next purchase first, things already at their best last + UP.filter(shedShows).sort(function (x, y) { var cx = state.up[x.id] >= x.costs.length ? 1e9 : x.costs[state.up[x.id]], cy = state.up[y.id] >= y.costs.length ? 1e9 : y.costs[state.up[y.id]]; return cx - cy; }).forEach(function (u) { var lv = state.up[u.id], max = u.costs.length, lockd = u.needs && !state.up[u.needs]; h += '
' + T(u.name) + (max > 1 ? pips(lv, max) : '') + '' + T(u.text) + '
'; h += lv >= max ? '✓ ' + T(max > 1 ? 'Best' : 'Owned') + '' : ''; @@ -416,13 +453,14 @@ side.innerHTML = h; Array.prototype.forEach.call(side.querySelectorAll('[data-buy]'), function (b) { b.addEventListener('click', function () { buy(b.dataset.buy); }); }); Array.prototype.forEach.call(side.querySelectorAll('[data-unlock]'), function (b) { b.addEventListener('click', function () { if (unlock(+b.dataset.unlock)) renderJournal(); }); }); - drawMap(); + if (maps) drawMap(); } function drawMap() { var c = $('map'), g = c.getContext('2d'), S = 12.5; function X(x) { return (x + 32) * S; } function Z(z) { return (z + 24) * S; } g.fillStyle = '#8c6a4a'; g.fillRect(0, 0, c.width, c.height); var gc = ['#86a85c', '#c9c2b0', '#c79a62', '#d6c8a4']; A.forEach(function (a, i) { g.fillStyle = gc[a.ground]; g.fillRect(X(a.x0) + 3, Z(a.z0) + 3, (a.x1 - a.x0) * S - 6, (a.z1 - a.z0) * S - 6); }); + var Hs = WR.HOUSE; g.fillStyle = '#a4543a'; g.fillRect(X(Hs.x0), Z(Hs.z0), (Hs.x1 - Hs.x0) * S, (Hs.z1 - Hs.z0) * S); g.fillStyle = '#c9c2b0'; WR.PATHS.forEach(function (h) { g.fillRect(X(h[0]), Z(h[2]), (h[1] - h[0]) * S, (h[3] - h[2]) * S); }); g.fillStyle = '#5f93a0'; [WR.POND, WR.FOUNTAIN].forEach(function (o) { g.beginPath(); g.arc(X(o.x), Z(o.z), o.r * S, 0, 7); g.fill(); }); 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); }); @@ -469,7 +507,7 @@ // still slow after the resolution has already dropped, and the player never chose: use fewer leaves if (avgMs > 36 && (!window.AutoRes || AutoRes.scale <= 0.5) && !state.set.picked && state.set.q !== 'low') { slowT += dt; if (slowT > 8) { slowT = 0; avgMs = 16; state.set.q = state.set.q === 'high' ? 'medium' : 'low'; applyQuality(); toast(T('Fewer leaves drawn to keep things smooth. You can change this in Settings')); save(); } } else slowT = 0; } else if (!inGame) { - if (frameN % 2 === 0) { var a = now * 0.00004; camera.position.set(Math.sin(a) * 3.6, 6.4, 12 + Math.cos(a) * 2.4); camera.lookAt(0, 0.6, 4); vm.ring.visible = vm.rake.visible = vm.handle.visible = vm.air.visible = false; draw(); } + if (frameN % 2 === 0) { var a = now * 0.00004; camera.position.set(Math.sin(a) * 2.6, 4.6, 13.4 + Math.cos(a) * 1.2); camera.lookAt(0, 1.1, 21); vm.ring.visible = vm.air.visible = vm.marker.visible = false; vm.poseRake(tmp, tmp2, camera.position, 1, 0, false); draw(); } } else if (needRender) { draw(); } needRender = false; } @@ -487,5 +525,5 @@ 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); }, tool: setTool, give: function (n) { state.acorns += n; acDirty = true; }, buy: buy, unlock: unlock, interact: interact, open: open, close: closeTop, save: save, touch: setTouch, - info: function () { return { awake: leaves.awakeCount(), n: leaves.N, alive: leaves.alive.slice(), acorns: state.acorns, bag: state.bagFill, playing: playing(), prompt: prompt && prompt.text }; } }; + 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/leaves.js b/e63334287a3deaa3/windrow/js/leaves.js index 1abc10c5..cc177f08 100644 --- a/e63334287a3deaa3/windrow/js/leaves.js +++ b/e63334287a3deaa3/windrow/js/leaves.js @@ -38,7 +38,7 @@ g.lineWidth = 1.4; g.strokeStyle = 'rgba(70,50,30,.38)'; for (i = -3; i <= 3; i++) { if (!i) continue; var z0 = i * n * .11; g.beginPath(); g.moveTo(0, z0 + n * .08); g.lineTo(n * .3, z0 - n * .06); g.moveTo(0, z0 + n * .08); g.lineTo(-n * .3, z0 - n * .06); g.stroke(); } g.restore(); }); - atlas = new THREE.CanvasTexture(c); atlas.anisotropy = 4; return atlas; + atlas = new THREE.CanvasTexture(c); atlas.anisotropy = 4; atlas.encoding = THREE.sRGBEncoding; return atlas; } // a flat card 1 long and 1 wide, showing shape k of the atlas function leafGeo(k) { @@ -55,7 +55,7 @@ // open ground of each area in square metres, and so how many leaves it gets at this quality (`mul` a square metre) var open = A.map(function () { return 0; }); for (c0 = 0; c0 < GW * GH; c0++) if (!solid[c0] && WR.areaOf[c0] >= 0 && inlet[c0] < 0) open[WR.areaOf[c0]] += CELL * CELL; - var counts = open.map(function (m2) { return Math.max(40, Math.round(m2 * mul)); }), N = counts.reduce(function (s, v) { return s + v; }, 0); + var counts = open.map(function (m2, i) { return Math.max(40, Math.round(m2 * mul * (A[i].dense || 1))); }), N = counts.reduce(function (s, v) { return s + v; }, 0); this.N = N; this.counts = counts; this.mul = mul; this.scene = scene; this.open = open; this.w = A.map(function (a, i) { return a.units / counts[i]; }); // acorn worth of one leaf, before upgrades this.fill = A.map(function (a, i) { return a.leaves / counts[i]; }); // how much sack one leaf takes @@ -80,7 +80,7 @@ function b64(u8) { var t = ''; for (var k = 0; k < u8.length; k += 8192) t += String.fromCharCode.apply(null, u8.subarray(k, k + 8192)); return btoa(t); } function unb64(t) { var b = atob(t), u = new Uint8Array(b.length); for (var k = 0; k < b.length; k++) u[k] = b.charCodeAt(k); return u; } function scatter(ai, first, keepShare) { - var a = A[ai], q = WR.rng(900 + ai * 31 + counts[ai]), spots = [], k, lim = Math.max(8, Math.round(mul * 0.55)); + var a = A[ai], q = WR.rng(900 + ai * 31 + counts[ai]), spots = [], k, lim = Math.max(8, Math.round(mul * 0.55 * (a.dense || 1))); WR.TREES.forEach(function (t) { if (t[0] > a.x0 && t[0] < a.x1 && t[1] > a.z0 && t[1] < a.z1) { spots.push([t[0], t[1], 2.2]); spots.push([t[0], t[1], 1.2]); } }); var extra = 8 + Math.round((a.x1 - a.x0) * (a.z1 - a.z0) / 30); for (k = 0; k < extra; k++) { var e = q(), ex = a.x0 + 1 + q() * (a.x1 - a.x0 - 2), ez = a.z0 + 1 + q() * (a.z1 - a.z0 - 2); @@ -150,7 +150,7 @@ m.frustumCulled = true; m.receiveShadow = true; m.matrixAutoUpdate = false; m.instanceMatrix.array.fill(0); m.boundingSphere = new THREE.Sphere(new THREE.Vector3((a.x0 + a.x1) / 2, 0, (a.z0 + a.z1) / 2), Math.hypot(a.x1 - a.x0, a.z1 - a.z0) / 2 + 9); var q3 = WR.rng(77 + ai * 13 + s2); - for (k = 0; k < L.length; k++) { col.set(a.pal[(q3() * a.pal.length) | 0]); var b = 0.8 + q3() * 0.35; col.r *= b; col.g *= b; col.b *= b; m.setColorAt(k, col); } + for (k = 0; k < L.length; k++) { col.set(a.pal[(q3() * a.pal.length) | 0]).convertSRGBToLinear(); var b = 0.75 + q3() * 0.4; col.r *= b; col.g *= b; col.b *= b; m.setColorAt(k, col); } if (m.instanceColor) m.instanceColor.needsUpdate = true; meshes.push(m); meshDirty.push(false); tileDirty.push(new Uint8Array(TILES)); tileStart.push(starts); scene.add(m); } @@ -167,7 +167,7 @@ (function (g) { var q = WR.rng(5150), cols = ['#8a5a2a', '#a06a2e', '#6f4a26', '#b9822f', '#7a4a22', '#c08a3a', '#5e4126']; for (var k = 0; k < 1500; k++) { g.fillStyle = cols[(q() * cols.length) | 0]; g.globalAlpha = 0.6 + q() * 0.4; g.beginPath(); g.ellipse(q() * 256, q() * 256, 1.5 + q() * 5, 1 + q() * 2.6, q() * 3.14, 0, 6.3); g.fill(); } g.globalAlpha = 0.7; g.strokeStyle = '#5a4026'; g.lineWidth = 1; for (k = 0; k < 60; k++) { var x = q() * 256, y = q() * 256; g.beginPath(); g.moveTo(x, y); g.lineTo(x + (q() - .5) * 16, y + (q() - .5) * 16); g.stroke(); } })(litC.getContext('2d')); - var litMap = new THREE.CanvasTexture(litC); litMap.wrapS = litMap.wrapT = THREE.RepeatWrapping; litMap.repeat.set(GW * CELL / 1.7, GH * CELL / 1.7); litMap.anisotropy = 4; + var litMap = new THREE.CanvasTexture(litC); litMap.encoding = THREE.sRGBEncoding; litMap.wrapS = litMap.wrapT = THREE.RepeatWrapping; litMap.repeat.set(GW * CELL / 1.7, GH * CELL / 1.7); litMap.anisotropy = 4; var litGeo = new THREE.PlaneGeometry(GW * CELL, GH * CELL); litGeo.rotateX(-Math.PI / 2); (function (uv) { for (var k = 0; k < uv.count; k++) uv.setY(k, 1 - uv.getY(k)); })(litGeo.attributes.uv); var litter = new THREE.Mesh(litGeo, new THREE.MeshLambertMaterial({ map: litMap, alphaMap: litTex, transparent: true, depthWrite: false })); @@ -307,7 +307,7 @@ // leaves low in a heap are sheltered by the ones on top var cov = cnt[lcell[l]] - 1 - rank[l]; if (cov > 2) f *= 2 / cov; wake(l); vx[l] += (hx * .72 + lx / hd * .28) * f; vz[l] += (hz * .72 + lz / hd * .28) * f; - vy[l] += f * (0.16 + ((l * 7919) % 13) / 13 * 0.3); spin[l] += (((l * 31) % 17) / 8.5 - 1) * f * 2.2; hit++; + vy[l] += f * (0.3 + ((l * 7919) % 13) / 13 * 0.55); spin[l] += (((l * 31) % 17) / 8.5 - 1) * f * 4; hit++; self.touched[area[l]] = true; }); return hit; @@ -350,6 +350,14 @@ self.touched[area[l]] = true; }); }; + // landing in leaves: they jump up and outward from the feet + this.burst = function (x, z, rad, power) { + eachIn(x - rad, z - rad, x + rad, z + rad, function (l) { + if (st[l] > AWAKE) return; var qx = px[l] - x, qz = pz[l] - z, d = Math.sqrt(qx * qx + qz * qz); if (d > rad) return; + var k = power * (1 - d / rad * 0.6), j = ((l * 97) % 23) / 23; wake(l); d = d || 1; + vx[l] += qx / d * k * (1.2 + j); vz[l] += qz / d * k * (1.2 + j); vy[l] += k * (1.1 + j * 1.4); spin[l] += (j - .5) * 14; self.touched[area[l]] = true; + }); + }; // chutes with the Draught grates reward draw nearby leaves in this.pull = function (x, z, rad, power, dt) { eachIn(x - rad, z - rad, x + rad, z + rad, function (l) { @@ -381,7 +389,7 @@ for (var i = 0; i < max; i++) { P.push({ life: 0 }); m4.makeScale(0, 0, 0); mesh.setMatrixAt(i, m4); mesh.setColorAt(i, col.set('#c8822c')); } this.spawn = function (x, y, z, vx, vy, vz, life, color, size, floorY) { var p = P[nextSlot]; p.x = x; p.y = y; p.z = z; p.vx = vx; p.vy = vy; p.vz = vz; p.life = p.max = life; p.s = size || .24; p.a = Math.random() * 6; p.b = Math.random() * 6; p.fl = floorY == null ? -1 : floorY; - mesh.setColorAt(nextSlot, col.set(color)); mesh.instanceColor.needsUpdate = true; nextSlot = (nextSlot + 1) % max; + mesh.setColorAt(nextSlot, col.set(color).convertSRGBToLinear()); mesh.instanceColor.needsUpdate = true; nextSlot = (nextSlot + 1) % max; }; this.step = function (dt) { var any = false; diff --git a/e63334287a3deaa3/windrow/js/models.js b/e63334287a3deaa3/windrow/js/models.js index 4cd4e89c..323e16a9 100644 --- a/e63334287a3deaa3/windrow/js/models.js +++ b/e63334287a3deaa3/windrow/js/models.js @@ -1,65 +1,109 @@ -/* Leaf Sweep: what you see of yourself. The gloves, sack and blower are drawn in a small scene of their own on top of - the garden (so they never poke through a wall); the rake is a real object in the garden, because its head is out - on the ground where the leaves are. Upgrades change these models: the sack swells, the rake head widens, the - blower's pipe grows. */ +/* Leaf Sweep: what you see of yourself. Rounded gloves on olive sleeves: open hands and the sack for gathering, a + fist on the blower's handle, and two fists that grip the rake's handle. The gloves, sack and blower are drawn in a + small scene of their own on top of the garden (so they never poke through a wall); the rake, the two fists on it + and their forearms are real objects in the garden, because the rake's head is out on the ground where the leaves + are. Upgrades change these models: the sack swells, the rake head widens, the blower's pipe grows. + Also here: the ring that shows the hands' reach, the wind streaks in the blower's stream, the finder's light + beams and the bouncing marker over a bin. */ (function () { 'use strict'; - var WR = window.WR, Builder = WR.Builder; + var WR = window.WR, Builder = WR.Builder, lin = WR.lin; + var TAN = '#e2be88', TAN2 = '#cfa56c', CUFF = '#c4552d', SLEEVE = '#5f7350'; + // a tube along +z, from z to z + len + function tube(b, x, y, z, r0, r1, len, color, seg) { var g = new THREE.CylinderGeometry(r1, r0, len, seg || 12); g.rotateX(Math.PI / 2); g.translate(0, 0, len / 2); b.add(g, color, x, y, z); } + function openGlove(side) { + var b = new Builder(); + b.ball(0, 0, 0, .046, .021, .056, TAN); + for (var f = 0; f < 4; f++) b.ball(-.031 + f * .0205, -.004 - Math.abs(f - 1.5) * .003, -.074 - (f === 1 || f === 2 ? .006 : 0), .0105, .011, .034, f % 2 ? TAN2 : TAN, 8); + b.ball(side * -.052, -.002, -.022, .012, .012, .031, TAN2, 8); + tube(b, 0, 0, .04, .04, .042, .035, CUFF); tube(b, 0, -.004, .07, .036, .046, .4, SLEEVE); + return b.mesh(); + } + function fist(side) { + var b = new Builder(); + b.ball(0, 0, 0, .042, .046, .05, TAN); b.ball(0, -.03, -.004, .04, .03, .046, TAN2); b.ball(side * -.03, .012, -.03, .014, .014, .03, TAN2, 8); + tube(b, 0, 0, .035, .043, .046, .04, CUFF); + return b.mesh(); + } WR.buildViewModels = function (scene, state) { var vm = { scene: new THREE.Scene(), cam: new THREE.PerspectiveCamera(58, 1, 0.02, 5) }; - vm.scene.add(new THREE.HemisphereLight(0xdfe8ee, 0x8a7a5a, 0.75)); var d = new THREE.DirectionalLight(0xffe6c0, 0.7); d.position.set(-1, 2, 1.5); vm.scene.add(d); + vm.scene.add(new THREE.HemisphereLight(lin('#cfe0f2'), lin('#a08a66'), 0.7)); var d = new THREE.DirectionalLight(lin('#ffe6c0'), 0.9); d.position.set(-1.2, 1.6, 1.4); vm.scene.add(d); - // hands and sack + // open hands and the sack var hands = vm.hands = new THREE.Group(); - function glove(side) { - var b = new Builder(), tan = '#d8b27c', dark = '#c29a64'; - b.box(0, 0, 0, .1, .04, .11, tan); // palm - for (var f = 0; f < 4; f++) b.box(-.036 + f * .024, .002, -.09 - (f === 1 || f === 2 ? .008 : 0), .02, .032, .075, f % 2 ? dark : tan, (f - 1.5) * -.06); - b.box(side * -.062, -.004, -.02, .026, .03, .07, dark, side * -.5); // thumb - b.box(0, 0, .075, .112, .05, .05, '#c4552d'); // cuff - b.box(0, -.004, .2, .095, .075, .2, '#6b7a55'); // sleeve - return b.mesh(); - } - var rh = vm.rh = glove(1); rh.position.set(.25, -.2, -.5); rh.rotation.set(-.35, .22, -.12); hands.add(rh); - var lh = glove(-1); lh.position.set(-.2, -.24, -.46); lh.rotation.set(-.5, -.5, .3); hands.add(lh); - var sackB = new Builder(); sackB.blob(0, 0, 0, .16, '#b99a66', 1.15, 9); sackB.cyl(0, .17, 0, .1, .12, .06, '#8f7447', 10); sackB.cyl(0, .2, 0, .085, .085, .01, '#3a2a18', 10); - var sack = vm.sack = sackB.mesh(); sack.position.set(-.3, -.43, -.6); hands.add(sack); - var fillB = new Builder(); fillB.blob(0, 0, 0, .09, '#c8822c', .6, 21); var fill = vm.sackFill = fillB.mesh(); fill.position.set(0, .2, 0); sack.add(fill); + var rh = vm.rh = openGlove(1); rh.position.set(.17, -.2, -.5); rh.rotation.set(.78, .42, -.2); hands.add(rh); + var sack = vm.sack = new THREE.Group(), sb = new Builder(); + sb.ball(0, 0, 0, .15, .17, .15, '#b99a66', 12); sb.ball(0, -.06, 0, .16, .12, .16, '#a98a58', 12); sb.cyl(0, .17, 0, .085, .11, .07, '#8f7447', 12); sb.cyl(0, .15, 0, .1, .1, .018, '#6b5230', 12); sb.cyl(0, .207, 0, .078, .078, .006, '#3a2a18', 12); + sack.add(sb.mesh()); sack.position.set(-.28, -.4, -.56); hands.add(sack); + var fb = new Builder(); fb.ball(0, 0, 0, .085, .05, .085, '#c8822c', 9); fb.ball(.03, .02, -.02, .05, .035, .05, '#d9a23a', 8); fb.ball(-.035, .015, .02, .045, .03, .045, '#b8552a', 8); + var fill = vm.sackFill = fb.mesh(); fill.position.set(0, .2, 0); sack.add(fill); + var lh = fist(-1); lh.position.set(.1, .2, .0); lh.rotation.set(.3, .2, 1.2); sack.add(lh); + var la = new Builder(); tube(la, 0, 0, 0, .036, .046, .4, SLEEVE); var lArm = la.mesh(); lArm.position.set(.13, .2, .03); lArm.rotation.set(.75, .35, 0); sack.add(lArm); vm.scene.add(hands); - // blower + // blower, with a fist on its handle var blower = vm.blower = new THREE.Group(), bb = new Builder(); - bb.box(0, 0, .05, .15, .17, .26, '#e0782a'); bb.box(0, .12, .05, .04, .05, .2, '#2f2f33'); bb.box(0, .0, .2, .13, .13, .06, '#2f2f33'); bb.cyl(.08, 0, .05, .06, .06, .02, '#3b3b40', 10); + bb.ball(0, 0, .06, .085, .092, .15, '#e37a2c', 12); bb.ball(0, .0, .17, .07, .075, .06, '#2f2f33', 10); bb.cyl(.084, 0, .06, .05, .05, .02, '#3b3b40', 12); + bb.box(0, .135, .05, .028, .028, .2, '#2f2f33'); bb.box(0, .1, -.04, .028, .08, .028, '#2f2f33'); bb.box(0, .1, .14, .028, .08, .028, '#2f2f33'); bb.ball(0, -.01, -.06, .058, .058, .05, '#c9651f', 10); var body = bb.mesh(); blower.add(body); - var pipe = vm.pipe = new THREE.Mesh(new THREE.CylinderGeometry(.036, .05, 1, 10), new THREE.MeshLambertMaterial({ color: 0x3b3b40 })); pipe.geometry.rotateX(-Math.PI / 2); pipe.geometry.translate(0, 0, -.5); pipe.position.set(0, -.02, -.07); blower.add(pipe); - var tip = vm.tip = new THREE.Mesh(new THREE.CylinderGeometry(.045, .04, .05, 10), new THREE.MeshLambertMaterial({ color: 0xe0b53a })); tip.geometry.rotateX(-Math.PI / 2); blower.add(tip); - blower.position.set(.3, -.3, -.42); blower.rotation.set(-.12, .16, 0); vm.scene.add(blower); - // a faint cone of moving air in the garden, so you can see where the blower reaches + var pipe = vm.pipe = new THREE.Mesh(new THREE.CylinderGeometry(.034, .05, 1, 12), new THREE.MeshLambertMaterial({ color: lin('#3b3b40') })); pipe.geometry.rotateX(-Math.PI / 2); pipe.geometry.translate(0, 0, -.5); pipe.position.set(0, -.02, -.07); blower.add(pipe); + var tip = vm.tip = new THREE.Mesh(new THREE.CylinderGeometry(.045, .038, .05, 12), new THREE.MeshLambertMaterial({ color: lin('#e0b53a') })); tip.geometry.rotateX(-Math.PI / 2); blower.add(tip); + var bf = fist(1); bf.position.set(0, .15, .05); bf.rotation.set(0, 0, -.2); bf.scale.setScalar(.8); blower.add(bf); + var ba = new Builder(); tube(ba, 0, 0, 0, .036, .048, .42, SLEEVE); var bArm = ba.mesh(); bArm.position.set(.005, .15, .085); bArm.rotation.set(.5, .3, 0); bArm.scale.set(.85, .85, 1); blower.add(bArm); + blower.position.set(.2, -.27, -.52); blower.rotation.set(-.1, .2, 0); vm.scene.add(blower); + // a faint cone of moving air in the garden, and streaks that run along it var airG = new THREE.ConeGeometry(1, 1, 14, 1, true); airG.translate(0, -.5, 0); airG.rotateX(-Math.PI / 2); - var air = vm.air = new THREE.Mesh(airG, new THREE.MeshBasicMaterial({ color: 0xffffff, transparent: true, opacity: .07, side: THREE.DoubleSide, depthWrite: false, fog: false })); air.visible = false; scene.add(air); + var air = vm.air = new THREE.Mesh(airG, new THREE.MeshBasicMaterial({ color: 0xffffff, transparent: true, opacity: .05, side: THREE.DoubleSide, depthWrite: false, fog: false })); air.visible = false; scene.add(air); + var sg = new THREE.PlaneGeometry(.03, 1); sg.rotateX(-Math.PI / 2); var streaks = [], tmpV = new THREE.Vector3(); + for (var i = 0; i < 14; i++) { var sm = new THREE.Mesh(sg, new THREE.MeshBasicMaterial({ color: 0xffffff, transparent: true, opacity: 0, depthWrite: false, fog: false, side: THREE.DoubleSide, blending: THREE.AdditiveBlending })); sm.visible = false; scene.add(sm); streaks.push({ m: sm, t: Math.random(), a: 0, b: 0, v: 1 }); } + // called every frame: `on` = the blower is running; origin, direction, reach and half-angle of its cone + vm.wind = function (dt, on, ox, oy, oz, dx, dy, dz, range, half) { + for (var k = 0; k < streaks.length; k++) { + var s = streaks[k]; if (!on) { s.m.visible = false; continue; } + s.t += dt * s.v; if (s.t >= 1 || !s.m.visible) { s.t = s.m.visible ? 0 : Math.random() * .8; s.a = (Math.random() * 2 - 1) * half * .8; s.b = (Math.random() * 2 - 1) * half * .35; s.v = 1.6 + Math.random() * 1.4; s.m.visible = true; } + var ca = Math.cos(s.a), sa = Math.sin(s.a), rx = dx * ca - dz * sa, rz = dx * sa + dz * ca, ry = dy + s.b, dist = 0.5 + s.t * (range - 0.8); + s.m.position.set(ox + rx * dist, Math.max(.08, oy + ry * dist), oz + rz * dist); tmpV.set(ox + rx * (dist + 1), Math.max(.08, oy + ry * (dist + 1)), oz + rz * (dist + 1)); s.m.lookAt(tmpV); + s.m.scale.set(1 + s.t * 2, 1, .5 + s.t * 1.1); s.m.material.opacity = Math.sin(Math.PI * s.t) * .3; + } + }; - // rake (in the garden itself) + // rake (in the garden itself): head, handle, two fists on the handle and their forearms var rake = vm.rake = new THREE.Group(); rake.visible = false; scene.add(rake); - var handle = vm.handle = new THREE.Mesh(new THREE.CylinderGeometry(.017, .02, 1, 7), new THREE.MeshLambertMaterial({ color: 0xb98a4e })); handle.geometry.rotateX(Math.PI / 2); handle.geometry.translate(0, 0, .5); scene.add(handle); handle.visible = false; + var handle = vm.handle = new THREE.Mesh(new THREE.CylinderGeometry(.017, .02, 1, 8), new THREE.MeshLambertMaterial({ color: lin('#b98a4e') })); handle.geometry.rotateX(Math.PI / 2); handle.geometry.translate(0, 0, .5); scene.add(handle); handle.visible = false; + vm.grip = []; + [1, -1].forEach(function (side) { var f = fist(side); f.visible = false; scene.add(f); var ab = new Builder(); tube(ab, 0, 0, 0, .036, .046, 1, SLEEVE); var arm = ab.mesh(); arm.visible = false; scene.add(arm); vm.grip.push({ fist: f, arm: arm, side: side }); }); var headMesh = null; vm.setRakeWidth = function (w, gold) { if (headMesh) { rake.remove(headMesh); headMesh.geometry.dispose(); } var b = new Builder(), n = Math.round(w / .1), metal = gold ? '#e0b53a' : '#6f7479'; b.box(0, .13, 0, w, .035, .05, metal); for (var i = 0; i <= n; i++) b.box(-w / 2 + i * w / n, .06, .02, .014, .13, .014, gold ? '#f0cf6a' : '#8a9096'); b.box(0, .16, -.05, .05, .05, .14, '#b98a4e'); - headMesh = b.mesh(); headMesh.castShadow = false; rake.add(headMesh); + headMesh = b.mesh(); rake.add(headMesh); + }; + // place the handle between the hands' end (a) and the head (b), and the fists and forearms along it + var q1 = new THREE.Vector3(), q2 = new THREE.Vector3(), up = new THREE.Vector3(); + vm.poseRake = function (a, b, eye, rx, rz, show) { + handle.visible = rake.visible = show; vm.grip.forEach(function (G) { G.fist.visible = G.arm.visible = show; }); if (!show) return; + handle.position.copy(a); handle.lookAt(b); handle.scale.z = a.distanceTo(b); + vm.grip.forEach(function (G, n) { + q1.copy(a).lerp(b, (n ? 0.5 : 0.08) / Math.max(1, a.distanceTo(b))); G.fist.position.copy(q1); G.fist.quaternion.copy(handle.quaternion); G.fist.rotateZ(G.side * 1.2); G.fist.rotateX(-1.2); + q2.set(eye.x + rx * (n ? -0.24 : 0.3), eye.y - 0.52, eye.z + rz * (n ? -0.24 : 0.3)); G.arm.position.copy(q1); G.arm.lookAt(q2); G.arm.scale.z = q1.distanceTo(q2); + }); }; // the ring that shows where the hands reach - var ring = vm.ring = new THREE.Mesh(new THREE.RingGeometry(.94, 1, 40), new THREE.MeshBasicMaterial({ color: 0xffffff, transparent: true, opacity: .55, depthWrite: false, fog: false })); ring.rotation.x = -Math.PI / 2; ring.visible = false; scene.add(ring); + 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); // 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: 0xffe27a, transparent: true, opacity: .5, depthWrite: false, fog: false }); - for (var i = 0; i < 8; i++) { var be = new THREE.Mesh(bg, bm); be.visible = false; scene.add(be); vm.beacons.push(be); } + 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); } + // a bouncing arrow over the bin a new player should go to + var mk = vm.marker = new THREE.Group(), mm = new THREE.MeshBasicMaterial({ color: lin('#ffd24a'), fog: false }); + var cone = new THREE.Mesh(new THREE.ConeGeometry(.22, .42, 14), mm); cone.rotation.x = Math.PI; mk.add(cone); var stem = new THREE.Mesh(new THREE.CylinderGeometry(.08, .08, .34, 10), mm); stem.position.y = .36; mk.add(stem); + mk.visible = false; scene.add(mk); vm.refresh = function () { - var up = state.up, fill = Math.min(1, state.bagFill / WR.sackCap(state)); - var s = 1 + up.sack * 0.13; sack.scale.set(s * (0.8 + fill * .35), s * (0.75 + fill * .4), s * (0.8 + fill * .35)); - vm.sackFill.visible = fill > 0.02; vm.sackFill.scale.setScalar(0.6 + fill * 0.7); - var len = 0.42 + up.nozzle * 0.11; pipe.scale.set(1 + up.nozzle * .08, 1 + up.nozzle * .08, len); tip.position.set(0, -.02, -.07 - len); - body.material.color.setHex([0xffffff, 0xfff0d0, 0xffd9a0, 0xffc070][up.power] || 0xffffff); + var up2 = state.up, fill2 = Math.min(1, state.bagFill / WR.sackCap(state)); + var s = 1 + up2.sack * 0.11; sack.scale.set(s * (0.82 + fill2 * .3), s * (0.76 + fill2 * .36), s * (0.82 + fill2 * .3)); + vm.sackFill.visible = fill2 > 0.02; vm.sackFill.scale.setScalar(0.6 + fill2 * 0.7); + var len = 0.42 + up2.nozzle * 0.11; pipe.scale.set(1 + up2.nozzle * .08, 1 + up2.nozzle * .08, len); tip.position.set(0, -.02, -.07 - len); vm.setRakeWidth(WR.rakeWidth(state), state.rewards.crown); }; vm.refresh(); diff --git a/e63334287a3deaa3/windrow/js/world.js b/e63334287a3deaa3/windrow/js/world.js index 1b5ebd4e..517e0e7c 100644 --- a/e63334287a3deaa3/windrow/js/world.js +++ b/e63334287a3deaa3/windrow/js/world.js @@ -5,11 +5,12 @@ (function () { 'use strict'; var WR = window.WR = window.WR || {}; - var CELL = WR.CELL = 0.25, X0 = WR.X0 = -33, Z0 = WR.Z0 = -25, GW = WR.GW = 248, GH = WR.GH = 168; + var CELL = WR.CELL = 0.25, X0 = WR.X0 = -33, Z0 = WR.Z0 = -25, GW = WR.GW = 248, GH = WR.GH = 216; var LAWN = 0, PAVE = 1, DECK = 2, GRAVEL = 3; WR.GROUND_FRICTION = [7.5, 3.2, 4.2, 6.0]; - /* The five areas. `units` is what all of an area's leaves are worth together before upgrades, however many leaves + /* The areas (the Front Yard, where a new player starts, is added last, further down, so the numbers saved for the + first five never change). `units` is what all of an area's leaves are worth together before upgrades, however many leaves the quality setting draws; `leaves` is the area's size in sack units (the sack and the hands are measured in these, so they do not depend on how many leaves the quality setting draws). `need` = [area, share cleared] to be allowed to unlock. */ WR.AREAS = [ { id: 'court', name: 'Gatehouse Court', x0: -12, x1: 12, z0: 0, z1: 20, ground: PAVE, leaves: 1500, units: 500, cost: 0, need: null, bonus: 100, @@ -66,6 +67,16 @@ [HEDGES, LAWNS, GRAVELS, GLASS].forEach(function (l) { l.forEach(function (o) { for (var k = 0; k < 4; k++) o[k] *= S; }); }); FOUNTAIN.r = 1.8; POND.r = 3.1; var SHED = [6.3, 9.3, 14.1, 15.7]; + /* 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, + 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 }); + 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; var solid = WR.solid = new Uint8Array(GW * GH), gtype = WR.gtype = new Uint8Array(GW * GH); @@ -84,9 +95,9 @@ if (cx * cx + cz * cz <= r * r && i >= 0 && j >= 0 && i < GW && j < GH) arr[i + j * GW] = v; } } - var WALLS = []; // [x0,x1,z0,z1] - function wallX(z, xa, xb, gaps) { segs(xa, xb, gaps).forEach(function (s) { WALLS.push([s[0], s[1], z - .25, z + .25]); }); } - function wallZ(x, za, zb, gaps) { segs(za, zb, gaps).forEach(function (s) { WALLS.push([x - .25, x + .25, s[0], s[1]]); }); } + var WALLS = [], TALL = 2.6, LOW = 1.15; // [x0,x1,z0,z1,height] + function wallX(z, xa, xb, gaps, h) { segs(xa, xb, gaps).forEach(function (s) { WALLS.push([s[0], s[1], z - .25, z + .25, h || TALL]); }); } + function wallZ(x, za, zb, gaps, h) { segs(za, zb, gaps).forEach(function (s) { WALLS.push([x - .25, x + .25, s[0], s[1], h || TALL]); }); } function segs(a, b, gaps) { var out = [], at = a; (gaps || []).sort(function (p, q) { return p - q; }).forEach(function (g) { out.push([at, g - 1.5]); at = g + 1.5; }); out.push([at, b]); return out; @@ -97,10 +108,14 @@ solid.fill(1); inlet.fill(-1); areaOf.fill(-1); WR.AREAS.forEach(function (a, n) { rect(solid, a.x0, a.x1, a.z0, a.z1, 0); rect(gtype, a.x0, a.x1, a.z0, a.z1, a.ground); rect(areaOf, a.x0, a.x1, a.z0, a.z1, n); }); LAWNS.forEach(function (r) { rect(gtype, r[0], r[1], r[2], r[3], LAWN); }); + PATHS.forEach(function (r) { rect(gtype, r[0], r[1], r[2], r[3], PAVE); }); GRAVELS.forEach(function (r) { rect(gtype, r[0], r[1], r[2], r[3], GRAVEL); }); WALLS.length = 0; var Wx = -40 * S, Ex = 36 * S, Nz = -30 * S, Sz = 20 * S, x1 = -12 * S, x2 = 12 * S; - wallX(Nz, Wx - .25, Ex + .25); wallX(Sz, Wx - .25, Ex + .25); wallZ(Wx, Nz, Sz); wallZ(Ex, Nz, Sz); + wallX(Nz, Wx - .25, Ex + .25); wallZ(Wx, Nz, Sz); wallZ(Ex, Nz, Sz); + // the south wall is low where the Front Yard meets it, so the big garden shows over it + wallX(Sz, Wx - .25, YARD.x0 - .25); wallX(Sz, YARD.x0 - .25, YARD.x1 + .25, [0], LOW); wallX(Sz, YARD.x1 + .25, Ex + .25); + wallZ(YARD.x0, Sz + .25, HOUSE.z0, null, LOW); wallZ(YARD.x1, Sz + .25, HOUSE.z0, null, LOW); wallZ(x1, Nz, Sz, [-15 * S]); wallZ(x2, Nz, Sz, [-15 * S, 10 * S]); wallX(0, x1, x2, [0]); wallX(0, x2, Ex); WALLS.forEach(function (w) { rect(solid, w[0], w[1], w[2], w[3], 1); }); WR.GATES.forEach(function (g) { var b = gateBox(g); rect(solid, b[0], b[1], b[2], b[3], 0); rect(gtype, b[0], b[1], b[2], b[3], GRAVEL); }); @@ -110,6 +125,7 @@ disc(solid, FOUNTAIN.x, FOUNTAIN.z, FOUNTAIN.r, 1); disc(solid, POND.x, POND.z, POND.r, 1); BENCHES.forEach(function (b) { if (b[2]) rect(solid, b[0] - .3, b[0] + .3, b[1] - .9, b[1] + .9, 1); else rect(solid, b[0] - .9, b[0] + .9, b[1] - .3, b[1] + .3, 1); }); rect(solid, SHED[0], SHED[1], SHED[2], SHED[3], 1); // potting shed + POTS.forEach(function (q) { disc(solid, q[0], q[1], 0.3, 1); }); WR.BINS.forEach(function (b) { rect(solid, b.x - .7, b.x + .7, b.z - .7, b.z + .7, 1); }); WR.sealed = seal(); WR.GATES.forEach(function (g) { if (!(unlocked && unlocked[g.area])) { var b = gateBox(g); rect(solid, b[0], b[1], b[2], b[3], 1); } }); @@ -165,17 +181,20 @@ function rng(seed) { var s = seed >>> 0; return function () { s = (s + 0x6D2B79F5) | 0; var t = Math.imul(s ^ (s >>> 15), 1 | s); t = (t + Math.imul(t ^ (t >>> 7), 61 | t)) ^ t; return ((t ^ (t >>> 14)) >>> 0) / 4294967296; }; } WR.rng = rng; function canvas(n, fn) { var c = document.createElement('canvas'); c.width = c.height = n; fn(c.getContext('2d'), n); return c; } - function tex(c, rep) { var t = new THREE.CanvasTexture(c); t.wrapS = t.wrapT = THREE.RepeatWrapping; t.anisotropy = 4; if (rep) t.repeat.set(rep, rep); return t; } + function tex(c, rep) { var t = new THREE.CanvasTexture(c); t.wrapS = t.wrapT = THREE.RepeatWrapping; t.anisotropy = 4; t.encoding = THREE.sRGBEncoding; if (rep) t.repeat.set(rep, rep); return t; } + WR.tex = tex; function speckle(g, n, count, cols, min, max, r) { for (var i = 0; i < count; i++) { g.fillStyle = cols[(r() * cols.length) | 0]; var s = min + r() * (max - min); g.fillRect(r() * n, r() * n, s, s); } } - function texLawn() { var r = rng(11); return canvas(256, function (g, n) { - g.fillStyle = '#5f8f3c'; g.fillRect(0, 0, n, n); speckle(g, n, 2600, ['#56853a', '#6a9a44', '#4f7c34', '#74a34b'], 2, 7, r); - g.lineWidth = 1.2; for (var i = 0; i < 1500; i++) { var x = r() * n, y = r() * n; g.strokeStyle = r() < .5 ? 'rgba(130,175,80,.55)' : 'rgba(50,90,35,.5)'; g.beginPath(); g.moveTo(x, y); g.lineTo(x + (r() - .5) * 5, y - 3 - r() * 6); g.stroke(); } + function texLawn() { var r = rng(11); return canvas(512, function (g, n) { + g.fillStyle = '#5c8c3a'; g.fillRect(0, 0, n, n); + for (var i = 0; i < 900; i++) { g.fillStyle = ['rgba(70,115,45,.35)', 'rgba(110,160,70,.3)', 'rgba(60,100,40,.3)'][(r() * 3) | 0]; g.beginPath(); g.ellipse(r() * n, r() * n, 10 + r() * 26, 8 + r() * 18, r() * 3, 0, 6.3); g.fill(); } + g.lineWidth = 1.3; g.lineCap = 'round'; for (i = 0; i < 9000; i++) { var x = r() * n, y = r() * n; g.strokeStyle = ['rgba(140,185,85,.6)', 'rgba(48,88,34,.55)', 'rgba(96,146,60,.6)', 'rgba(170,200,100,.4)'][(r() * 4) | 0]; g.beginPath(); g.moveTo(x, y); g.lineTo(x + (r() - .5) * 5, y - 3 - r() * 7); g.stroke(); } }); } - function texPave() { var r = rng(12); return canvas(256, function (g, n) { - g.fillStyle = '#8e8a80'; g.fillRect(0, 0, n, n); - var rows = [[0, 128, 128], [128, 256, 0]]; - for (var y = 0; y < 4; y++) for (var x = -1; x < 3; x++) { var ox = (y % 2) * 64 + x * 128, sh = 150 + (r() * 34 | 0); g.fillStyle = 'rgb(' + (sh + 8) + ',' + (sh + 2) + ',' + (sh - 10) + ')'; g.fillRect(ox + 2, y * 64 + 2, 124, 60); if (ox + 128 > n) g.fillRect(ox - n + 2, y * 64 + 2, 124, 60); } - speckle(g, n, 1800, ['rgba(0,0,0,.06)', 'rgba(255,255,255,.07)', 'rgba(90,70,40,.08)'], 1, 4, r); + function texPave() { var r = rng(12); return canvas(512, function (g, n) { + g.fillStyle = '#6f6a60'; g.fillRect(0, 0, n, n); + for (var y = 0; y < 4; y++) for (var x = -1; x < 3; x++) { var ox = (y % 2) * 128 + x * 256, sh = 158 + (r() * 30 | 0), oy = y * 128; + [ox, ox - n].forEach(function (px) { g.fillStyle = 'rgb(' + (sh + 10) + ',' + (sh + 3) + ',' + (sh - 12) + ')'; g.fillRect(px + 4, oy + 4, 248, 120); + g.fillStyle = 'rgba(255,255,255,.16)'; g.fillRect(px + 4, oy + 4, 248, 3); g.fillRect(px + 4, oy + 4, 3, 120); g.fillStyle = 'rgba(0,0,0,.14)'; g.fillRect(px + 4, oy + 121, 248, 3); g.fillRect(px + 249, oy + 4, 3, 120); }); } + speckle(g, n, 5200, ['rgba(0,0,0,.05)', 'rgba(255,255,255,.06)', 'rgba(90,70,40,.07)'], 1, 5, r); }); } function texDeck() { var r = rng(13); return canvas(256, function (g, n) { for (var p = 0; p < 4; p++) { var sh = r(); g.fillStyle = 'rgb(' + (150 + sh * 26 | 0) + ',' + (104 + sh * 20 | 0) + ',' + (62 + sh * 14 | 0) + ')'; g.fillRect(0, p * 64, n, 64); @@ -183,21 +202,26 @@ g.fillStyle = '#4c311a'; g.fillRect(0, p * 64, n, 3); var jx = r() * n; g.fillRect(jx, p * 64, 2, 64); g.fillStyle = '#3a2513'; g.fillRect(jx + 6, p * 64 + 14, 3, 3); g.fillRect(jx + 6, p * 64 + 46, 3, 3); } }); } function texGravel() { var r = rng(14); return canvas(256, function (g, n) { g.fillStyle = '#b9a987'; g.fillRect(0, 0, n, n); speckle(g, n, 5200, ['#a59373', '#cbbd9c', '#948264', '#d8ccae', '#857456'], 2, 5, r); }); } - function texBrick() { var r = rng(15); return canvas(256, function (g, n) { - g.fillStyle = '#b9ae9c'; g.fillRect(0, 0, n, n); - for (var y = 0; y < 8; y++) for (var x = -1; x < 4; x++) { var ox = x * 64 + (y % 2) * 32, t = r(); g.fillStyle = 'rgb(' + (150 + t * 40 | 0) + ',' + (84 + t * 26 | 0) + ',' + (62 + t * 20 | 0) + ')'; g.fillRect(ox + 2, y * 32 + 2, 60, 28); } - speckle(g, n, 1200, ['rgba(0,0,0,.07)', 'rgba(255,240,220,.08)'], 1, 4, r); + function texBrick() { var r = rng(15); return canvas(512, function (g, n) { + g.fillStyle = '#c9bda8'; g.fillRect(0, 0, n, n); + for (var y = 0; y < 16; y++) for (var x = -1; x < 8; x++) { var ox = x * 64 + (y % 2) * 32, t = r(), dk = r() < .12 ? -34 : 0; + g.fillStyle = 'rgb(' + (158 + t * 36 + dk | 0) + ',' + (88 + t * 24 + dk * .6 | 0) + ',' + (64 + t * 18 + dk * .5 | 0) + ')'; g.fillRect(ox + 2, y * 32 + 2, 60, 28); + g.fillStyle = 'rgba(255,230,200,.13)'; g.fillRect(ox + 2, y * 32 + 2, 60, 3); g.fillStyle = 'rgba(40,10,0,.16)'; g.fillRect(ox + 2, y * 32 + 27, 60, 3); } + speckle(g, n, 3600, ['rgba(0,0,0,.06)', 'rgba(255,240,220,.07)'], 1, 4, r); }); } function texHedge() { var r = rng(16); return canvas(256, function (g, n) { g.fillStyle = '#2f5a2c'; g.fillRect(0, 0, n, n); for (var i = 0; i < 2600; i++) { g.fillStyle = ['#356a31', '#28502a', '#417a38', '#234724', '#4d8a3e'][(r() * 5) | 0]; g.beginPath(); g.ellipse(r() * n, r() * n, 2 + r() * 4, 1.5 + r() * 2.5, r() * 3.14, 0, 6.3); g.fill(); } }); } + // colours are written as ordinary screen colours and turned into linear light here (the renderer shows sRGB) + function lin(c) { return new THREE.Color(c).convertSRGBToLinear(); } + WR.lin = lin; // a pile of boxes, cylinders and blobs with a colour each, drawn as one mesh function Builder() { this.p = []; this.n = []; this.c = []; } Builder.prototype.add = function (geo, color, x, y, z, ry, jitter) { var g = geo.index ? geo.toNonIndexed() : geo, m = new THREE.Matrix4().makeRotationY(ry || 0); m.setPosition(x, y, z); g.applyMatrix4(m); - var P = g.attributes.position.array, N = g.attributes.normal.array, col = new THREE.Color(color), j = jitter || 0; + var P = g.attributes.position.array, N = g.attributes.normal.array, col = lin(color), j = jitter || 0; for (var i = 0; i < P.length; i += 9) { var k = 1 + (Math.sin(i * 12.9898 + x * 7.1) * 43758.5453 % 1) * j; for (var v = 0; v < 9; v += 3) { this.p.push(P[i + v], P[i + v + 1], P[i + v + 2]); this.n.push(N[i + v], N[i + v + 1], N[i + v + 2]); this.c.push(col.r * k, col.g * k, col.b * k); } } g.dispose(); return this; @@ -209,6 +233,10 @@ for (var i = 0; i < P.length; i += 3) { var key = P[i].toFixed(2) + P[i + 1].toFixed(2) + P[i + 2].toFixed(2), k = cache[key] || (cache[key] = 0.82 + rr() * 0.36); P[i] *= k; P[i + 1] *= k * (sy || 1); P[i + 2] *= k; } g.computeVertexNormals(); return this.add(g, color, x, y, z, 0, 0.16); }; + // a smooth ball, stretched to (rx,ry,rz) + Builder.prototype.ball = function (x, y, z, rx, ry, rz, color, seg) { var g = new THREE.SphereGeometry(1, seg || 10, Math.max(6, (seg || 10) - 2)); g.scale(rx, ry, rz); g.computeVertexNormals(); return this.add(g, color, x, y, z); }; + // ready-made triangles: positions, normals, colours (already linear) + Builder.prototype.raw = function (P, N, C) { for (var i = 0; i < P.length; i++) { this.p.push(P[i]); this.n.push(N[i]); this.c.push(C[i]); } return this; }; Builder.prototype.mesh = function (mat) { var g = new THREE.BufferGeometry(); g.setAttribute('position', new THREE.Float32BufferAttribute(this.p, 3)); g.setAttribute('normal', new THREE.Float32BufferAttribute(this.n, 3)); g.setAttribute('color', new THREE.Float32BufferAttribute(this.c, 3)); @@ -216,10 +244,10 @@ }; WR.Builder = Builder; // boxes sharing one repeating texture, with texture coordinates taken from where each face is in the world - function texBoxes(list, h, y0, scale) { + function texBoxes(list, h0, y0, scale) { var p = [], n = [], uv = []; list.forEach(function (b) { - var g = new THREE.BoxGeometry(b[1] - b[0], h, b[3] - b[2]).toNonIndexed(); g.translate((b[0] + b[1]) / 2, y0 + h / 2, (b[2] + b[3]) / 2); + var h = h0 || b[4], g = new THREE.BoxGeometry(b[1] - b[0], h, b[3] - b[2]).toNonIndexed(); g.translate((b[0] + b[1]) / 2, y0 + h / 2, (b[2] + b[3]) / 2); var P = g.attributes.position.array, N = g.attributes.normal.array; for (var i = 0; i < P.length; i += 3) { p.push(P[i], P[i + 1], P[i + 2]); n.push(N[i], N[i + 1], N[i + 2]); if (Math.abs(N[i + 1]) > .5) uv.push(P[i] * scale, P[i + 2] * scale); else if (Math.abs(N[i]) > .5) uv.push(P[i + 2] * scale, P[i + 1] * scale); else uv.push(P[i] * scale, P[i + 1] * scale); } @@ -232,61 +260,130 @@ var G = new THREE.BufferGeometry(); G.setAttribute('position', new THREE.Float32BufferAttribute(p, 3)); G.setAttribute('normal', new THREE.Float32BufferAttribute(n, 3)); G.setAttribute('uv', new THREE.Float32BufferAttribute(uv, 2)); return G; } function signTexture(lines) { - return new THREE.CanvasTexture(canvas(256, function (g) { + var t = new THREE.CanvasTexture(canvas(256, function (g) { g.fillStyle = '#6b4526'; g.fillRect(0, 64, 256, 128); g.fillStyle = '#f3e3bd'; g.fillRect(6, 70, 244, 116); g.fillStyle = '#3b2613'; g.textAlign = 'center'; g.font = '700 30px Fraunces, Georgia, serif'; g.fillText(lines[0], 128, 116, 232); g.font = '600 24px Nunito, system-ui, sans-serif'; g.fillStyle = '#7a4a1e'; g.fillText(lines[1] || '', 128, 160, 232); - })); + })); t.encoding = THREE.sRGBEncoding; return t; + } + + + /* ---------- the things that stand in the garden ---------- */ + var CANOPY = ['#d98a2b', '#c8502a', '#e2b53c', '#b83e25', '#d9a13a', '#a9ad3d', '#cf6f2a']; + // a tree: a tapered trunk with two limbs and a crown of rounded, lumpy masses, lighter on top and darker beneath + function tree(B, x, z, s, n, fine) { + var H = 3.1 * s, bark = '#5b4332', g, k; + B.cyl(x, H / 2, z, 0.17 * s, 0.33 * s, H, bark, 9); B.cyl(x, 0.12, z, 0.34 * s, 0.5 * s, 0.24, bark, 9); + [[0.62, 0.9, 1.5], [-0.55, 2.6, 1.3], [0.4, 4.4, 1.1]].forEach(function (b) { + g = new THREE.CylinderGeometry(0.06 * s, 0.12 * s, b[2] * s, 6); g.translate(0, b[2] * s / 2, 0); g.rotateZ(b[0]); g.rotateY(b[1] + n); B.add(g, bark, x, H * 0.72, z); }); + var c1 = lin(CANOPY[n % CANOPY.length]), c2 = lin(CANOPY[(n + 3) % CANOPY.length]), col = new THREE.Color(); + [[0, 1.15, 0, 2.05], [1.25, 0.45, 0.45, 1.4], [-1.15, 0.6, -0.7, 1.5], [0.25, 0.4, -1.25, 1.25], [-0.4, 1.95, 0.35, 1.2], [0.3, 0.5, 1.2, 1.15]].forEach(function (L, li) { + var r = L[3] * s, geo = new THREE.IcosahedronGeometry(1, fine ? 2 : 1), P = geo.attributes.position.array, pp = [], nn = [], cc = [], sd = n * 1.7 + li * 2.3; + for (k = 0; k < P.length; k += 3) { + var nx = P[k], ny = P[k + 1], nz = P[k + 2], d = 1 + 0.15 * Math.sin(3.1 * nx + sd) * Math.sin(2.7 * ny + sd * 1.3) + 0.11 * Math.sin(4.7 * nz + sd * 2.1) + 0.06 * Math.sin(9 * nx + 7 * nz + sd); + pp.push(x + L[0] * s + nx * r * d, H + L[1] * s + ny * r * d * 0.8, z + L[2] * s + nz * r * d); nn.push(nx, ny, nz); + var mix = 0.5 + 0.5 * Math.sin(5.3 * nx + 4.1 * nz + sd * 3), shade = 0.58 + 0.5 * Math.max(0, ny * 0.5 + 0.5) + 0.12 * Math.sin(11 * nx + 13 * ny + 9 * nz + sd); + col.copy(c1).lerp(c2, mix * 0.35); cc.push(col.r * shade, col.g * shade, col.b * shade); + } + B.raw(pp, nn, cc); geo.dispose(); + }); + } + function bench(B, x, z, turned) { + var ry = turned ? Math.PI / 2 : 0, wood = '#9a6638', wood2 = '#8a5a30', iron = '#2d2b2a', q; + function at(lx, y, lz, w, h, d, c) { var X = turned ? lz : lx, Zz = turned ? lx : lz; B.box(x + X, y, z + Zz, w, h, d, c, ry); } + for (q = 0; q < 3; q++) at(0, 0.44, -0.16 + q * 0.16, 1.8, 0.04, 0.13, q % 2 ? wood2 : wood); + for (q = 0; q < 2; q++) at(0, 0.66 + q * 0.17, 0.25, 1.8, 0.12, 0.04, q % 2 ? wood2 : wood); + [-0.82, 0.82].forEach(function (e) { at(e, 0.22, -0.2, 0.06, 0.44, 0.06, iron); at(e, 0.44, 0.24, 0.06, 0.88, 0.06, iron); at(e, 0.6, 0, 0.07, 0.05, 0.5, iron); at(e, 0.4, 0, 0.05, 0.05, 0.46, iron); }); + } + function house(B, glow) { + var Hs = WR.HOUSE, cx = 0, z0 = Hs.z0, z1 = Hs.z1, zc = (z0 + z1) / 2, w = Hs.x1 - Hs.x0, d = z1 - z0, wall = '#eadfc4', trim = '#f6f1e4', roof = '#a4543a', green = '#35604a', q; + B.box(cx, 1.55, zc, w, 3.1, d, wall); B.box(cx, 0.3, zc, w + 0.12, 0.6, d + 0.12, '#9a5b42'); + // roof: two slopes, a ridge, gable ends, a chimney + var half = d / 2 + 0.35, rise = 1.9, len = Math.hypot(half, rise), ang = Math.atan2(rise, half), g1 = new THREE.BoxGeometry(w + 0.8, 0.16, len); g1.rotateX(-ang); B.add(g1, roof, cx, 3.1 + rise / 2, zc - half / 2); + var g2 = new THREE.BoxGeometry(w + 0.8, 0.16, len); g2.rotateX(ang); B.add(g2, '#93482f', cx, 3.1 + rise / 2, zc + half / 2); + B.box(cx, 3.1 + rise + 0.04, zc, w + 0.9, 0.14, 0.24, '#7d3d28'); + var wc = lin(wall), gp = [], gn = [], gcc = []; + [-1, 1].forEach(function (sd) { var X = sd * w / 2, pts = sd < 0 ? [[z0, 3.1], [z1, 3.1], [zc, 3.1 + rise]] : [[z1, 3.1], [z0, 3.1], [zc, 3.1 + rise]]; pts.forEach(function (p2) { gp.push(X, p2[1], p2[0]); gn.push(sd, 0, 0); gcc.push(wc.r, wc.g, wc.b); }); }); + B.raw(gp, gn, gcc); + B.box(3.1, 4.9, zc + 0.9, 0.75, 1.7, 0.75, '#9a5b42'); B.box(3.1, 5.8, zc + 0.9, 0.9, 0.12, 0.9, '#d8d0c0'); + // the door, its step and a small canopy + var zf = z0 - 0.02; + B.box(0, 1.2, zf, 1.36, 2.4, 0.1, trim); B.box(0, 1.14, zf - 0.04, 1.06, 2.16, 0.08, green); + [[-0.26, 1.62], [0.26, 1.62], [-0.26, 0.66], [0.26, 0.66]].forEach(function (pn) { B.box(pn[0], pn[1], zf - 0.085, 0.36, pn[1] > 1 ? 0.72 : 0.8, 0.02, '#2b4f3d'); }); + B.ball(0.4, 1.12, zf - 0.11, 0.045, 0.045, 0.045, '#e0b53a'); B.box(0, 2.56, zf - 0.34, 1.9, 0.1, 0.8, roof); + B.box(0, 0.09, z0 - 0.42, 2.0, 0.18, 0.84, '#c9c2b2'); B.box(0, 0.045, z0 - 0.98, 2.3, 0.09, 0.34, '#bdb5a4'); B.box(0, 0.105, z0 - 0.5, 0.95, 0.03, 0.5, '#7b5536'); + // windows with shutters; the glass is its own bright mesh so it glows a little + [-3.05, 3.05].forEach(function (wx) { + B.box(wx, 1.75, zf, 1.56, 1.46, 0.1, trim); glow.box(wx, 1.75, zf - 0.03, 1.36, 1.26, 0.06, '#ffd88c'); + B.box(wx, 1.75, zf - 0.07, 0.05, 1.26, 0.03, trim); B.box(wx, 1.75, zf - 0.07, 1.36, 0.05, 0.03, trim); B.box(wx, 1.0, zf - 0.07, 1.7, 0.07, 0.2, trim); + [-1, 1].forEach(function (sd) { B.box(wx + sd * 0.98, 1.75, zf - 0.03, 0.38, 1.46, 0.05, green); }); + B.box(wx, 0.86, zf - 0.2, 1.5, 0.2, 0.26, '#7b5536'); for (q = 0; q < 6; q++) B.ball(wx - 0.62 + q * 0.25, 1.02, zf - 0.2, 0.15, 0.13, 0.13, ['#c8452a', '#e08a32', '#d9a23a'][q % 3], 7); + }); + glow.ball(0.95, 2.05, zf - 0.12, 0.09, 0.12, 0.09, '#fff2c8'); B.box(0.95, 2.22, zf - 0.08, 0.05, 0.2, 0.14, '#2d2b2a'); + POTS.forEach(function (pt, i) { B.cyl(pt[0], 0.22, pt[1], 0.26, 0.19, 0.44, '#b0623f', 12); B.ball(pt[0], 0.62, pt[1], 0.3, 0.3, 0.3, i ? '#4d8a3e' : '#3f7d3a', 9); }); + } + function skyTexture(az) { + var c = document.createElement('canvas'); c.width = 1024; c.height = 512; var g = c.getContext('2d'), r = rng(31), gr = g.createLinearGradient(0, 0, 0, 512); + gr.addColorStop(0, '#3a74bd'); gr.addColorStop(0.3, '#6fa6dc'); gr.addColorStop(0.43, '#a9cbe8'); gr.addColorStop(0.485, '#dfe6e4'); gr.addColorStop(0.5, '#f6dfb6'); gr.addColorStop(1, '#f1d3a2'); g.fillStyle = gr; g.fillRect(0, 0, 1024, 512); + var sx = az * 1024, sy = 512 * 0.36; + [0, -1024, 1024].forEach(function (o) { var sg = g.createRadialGradient(sx + o, sy, 0, sx + o, sy, 300); sg.addColorStop(0, 'rgba(255,244,214,.95)'); sg.addColorStop(0.07, 'rgba(255,236,190,.7)'); sg.addColorStop(0.35, 'rgba(255,214,150,.22)'); sg.addColorStop(1, 'rgba(255,214,150,0)'); g.fillStyle = sg; g.fillRect(0, 0, 1024, 512); }); + for (var i = 0; i < 11; i++) { var x = r() * 1024, y = 70 + r() * 120, n = 4 + (r() * 5 | 0), wv = 60 + r() * 90; + for (var k = 0; k < n; k++) { var px = x + (r() - .5) * wv * 1.6, py = y + (r() - .5) * 16, rad = 16 + r() * 30; [0, -1024, 1024].forEach(function (o) { var cg = g.createRadialGradient(px + o, py, 0, px + o, py, rad * 1.8); cg.addColorStop(0, 'rgba(255,250,240,.3)'); cg.addColorStop(1, 'rgba(255,250,240,0)'); g.fillStyle = cg; g.beginPath(); g.ellipse(px + o, py, rad * 1.8, rad * 0.7, 0, 0, 6.3); g.fill(); }); } } + var t = new THREE.CanvasTexture(c); t.encoding = THREE.sRGBEncoding; return t; } WR.buildWorld = function (scene) { var T = WR.T || function (s) { return s; }; - var out = { gates: [], bins: [], shadowCasters: [] }; - // sky and far ground - var sg = new THREE.SphereGeometry(400, 24, 12), sc = [], sp = sg.attributes.position.array, c0 = new THREE.Color('#f6d9a8'), c1 = new THREE.Color('#9cc3e0'), c2 = new THREE.Color('#5f93c9'), tc = new THREE.Color(); - for (var i = 0; i < sp.length; i += 3) { var h = Math.max(0, sp[i + 1] / 400); if (h < .25) tc.copy(c0).lerp(c1, h / .25); else tc.copy(c1).lerp(c2, Math.min(1, (h - .25) / .6)); sc.push(tc.r, tc.g, tc.b); } - sg.setAttribute('color', new THREE.Float32BufferAttribute(sc, 3)); - var sky = new THREE.Mesh(sg, new THREE.MeshBasicMaterial({ vertexColors: true, side: THREE.BackSide, fog: false, depthWrite: false })); sky.renderOrder = -10; scene.add(sky); - var sun = new THREE.Mesh(new THREE.CircleGeometry(26, 24), new THREE.MeshBasicMaterial({ color: 0xfff1cf, fog: false, transparent: true, opacity: .9, depthWrite: false })); - sun.position.set(-190, 150, 200); sun.lookAt(0, 0, 0); sun.renderOrder = -9; scene.add(sun); - scene.fog = new THREE.Fog(0xead6b2, 45, 210); - var far = new THREE.Mesh(new THREE.PlaneGeometry(900, 900), new THREE.MeshLambertMaterial({ color: 0x6f8a45 })); far.rotation.x = -Math.PI / 2; far.position.y = -0.03; scene.add(far); + var out = { gates: [], bins: [] }; + // light first, so the sky can put its glow where the sun is: a low warm sun from the south-west, cool fill from the sky + var sunPos = new THREE.Vector3(-36, 30, 42), sunAt = new THREE.Vector3(-1.6, 0, 2), sd = sunPos.clone().sub(sunAt).normalize(); + scene.add(new THREE.HemisphereLight(lin('#bcd6f2'), lin('#9a8563'), 0.62)); scene.add(new THREE.AmbientLight(0xffffff, 0.05)); + var dir = new THREE.DirectionalLight(lin('#ffe2b4'), 1.0); dir.position.copy(sunPos); dir.target.position.copy(sunAt); scene.add(dir); scene.add(dir.target); + var cam = dir.shadow.camera; cam.left = -40; cam.right = 40; cam.top = 40; cam.bottom = -40; cam.near = 5; cam.far = 150; dir.shadow.mapSize.set(2048, 2048); dir.shadow.bias = -0.0008; dir.shadow.normalBias = 0.03; + out.sun = dir; out.sunDir = sd; + var az = Math.atan2(sd.z, -sd.x) / (Math.PI * 2); if (az < 0) az += 1; + var sky = new THREE.Mesh(new THREE.SphereGeometry(400, 32, 16), new THREE.MeshBasicMaterial({ map: skyTexture(az), side: THREE.BackSide, fog: false, depthWrite: false, toneMapped: false })); sky.renderOrder = -10; scene.add(sky); + scene.fog = new THREE.Fog(lin('#f1d9b0'), 50, 230); + var far = new THREE.Mesh(new THREE.PlaneGeometry(900, 900), new THREE.MeshLambertMaterial({ color: lin('#74904a') })); far.rotation.x = -Math.PI / 2; far.position.y = -0.03; scene.add(far); // ground, one mesh per surface - var mats = [texLawn(), texPave(), texDeck(), texGravel()].map(function (c, i) { return new THREE.MeshLambertMaterial({ map: tex(c) }); }); + var mats = [texLawn(), texPave(), texDeck(), texGravel()].map(function (c) { return new THREE.MeshLambertMaterial({ map: tex(c) }); }); var scales = [0.5, 0.5, 0.8, 0.6], lists = [[], [], [], []]; WR.AREAS.forEach(function (a) { lists[a.ground].push([a.x0, a.x1, a.z0, a.z1]); }); lists.forEach(function (l, i) { if (!l.length) return; var m = new THREE.Mesh(groundGeo(l, 0, scales[i]), mats[i]); m.receiveShadow = true; scene.add(m); }); var over = new THREE.Mesh(groundGeo(LAWNS, 0.012, scales[0]), mats[0]); over.receiveShadow = true; scene.add(over); - var gl = GRAVELS.concat(WR.GATES.map(gateBox)); - var gv = new THREE.Mesh(groundGeo(gl, 0.008, scales[3]), mats[3]); gv.receiveShadow = true; scene.add(gv); - // walls and hedges - var wall = new THREE.Mesh(texBoxes(WALLS, 2.6, 0, 0.42), new THREE.MeshLambertMaterial({ map: tex(texBrick()) })); wall.castShadow = wall.receiveShadow = true; scene.add(wall); - var cap = new THREE.Mesh(texBoxes(WALLS.map(function (w) { return [w[0] - .08, w[1] + .08, w[2] - .08, w[3] + .08]; }), 0.14, 2.6, 0.3), new THREE.MeshLambertMaterial({ color: 0xcfc6b4 })); scene.add(cap); + var pth = new THREE.Mesh(groundGeo(PATHS, 0.012, scales[1]), mats[1]); pth.receiveShadow = true; scene.add(pth); + var gv = new THREE.Mesh(groundGeo(GRAVELS.concat(WR.GATES.map(gateBox)), 0.008, scales[3]), mats[3]); gv.receiveShadow = true; scene.add(gv); + // walls with piers and caps; hedges + var piers = [], B = new Builder(), glowB = new Builder(), r = rng(77), k, capC = '#d6cdbb'; + WALLS.forEach(function (w) { + var alongX = (w[1] - w[0]) > (w[3] - w[2]), a0 = alongX ? w[0] : w[2], a1 = alongX ? w[1] : w[3], n = Math.max(1, Math.round((a1 - a0) / 4.2)), h = w[4]; + B.box((w[0] + w[1]) / 2, h + 0.06, (w[2] + w[3]) / 2, w[1] - w[0] + 0.14, 0.12, w[3] - w[2] + 0.14, capC); + for (var q = 0; q <= n; q++) { var t = a0 + (a1 - a0) * q / n, px = alongX ? t : (w[0] + w[1]) / 2, pz = alongX ? (w[2] + w[3]) / 2 : t; + piers.push([px - 0.34, px + 0.34, pz - 0.34, pz + 0.34, h + 0.22]); B.box(px, h + 0.29, pz, 0.84, 0.14, 0.84, capC); B.box(px, h + 0.41, pz, 0.5, 0.1, 0.5, capC); } + }); + var brick = new THREE.MeshLambertMaterial({ map: tex(texBrick()) }); + var wall = new THREE.Mesh(texBoxes(WALLS.concat(piers), 0, 0, 0.42), brick); wall.castShadow = wall.receiveShadow = true; scene.add(wall); var hedge = new THREE.Mesh(texBoxes(HEDGES, 1.9, 0, 0.5), new THREE.MeshLambertMaterial({ map: tex(texHedge()) })); hedge.castShadow = hedge.receiveShadow = true; scene.add(hedge); // props, all one mesh - var B = new Builder(), r = rng(77); - var canopy = ['#d98a2b', '#c8502a', '#e2b53c', '#b83e25', '#d9a13a', '#9fae3d', '#cf6f2a']; - TREES.forEach(function (t, n) { - var s = t[2], x = t[0], z = t[1], hgt = 3.4 * s; - B.cyl(x, hgt / 2, z, 0.2 * s, 0.34 * s, hgt, '#5d4330', 7); - B.blob(x, hgt + 0.9 * s, z, 2.1 * s, canopy[n % canopy.length], 0.8, n + 1); - B.blob(x + 1.3 * s, hgt + 0.3 * s, z + 0.5 * s, 1.4 * s, canopy[(n + 2) % canopy.length], 0.8, n + 31); - B.blob(x - 1.1 * s, hgt + 0.5 * s, z - 0.8 * s, 1.5 * s, canopy[(n + 4) % canopy.length], 0.8, n + 61); - }); - // beyond the walls: a ring of trees so the horizon is not empty - for (var k = 0; k < 46; k++) { var ang = k / 46 * 6.283 + r() * .1, rad = 62 + r() * 30, tx = -2 + Math.cos(ang) * rad * .95, tz = -4 + Math.sin(ang) * rad * .78, ss = 2.2 + r() * 1.6; - B.cyl(tx, 2 * ss, tz, .25 * ss, .4 * ss, 4 * ss, '#5a4634', 5); B.blob(tx, 5.2 * ss, tz, 2.6 * ss, canopy[k % canopy.length], .9, k + 200); } - BENCHES.forEach(function (b) { var ry = b[2] ? Math.PI / 2 : 0; B.box(b[0], .42, b[1], 1.8, .08, .5, '#8a5a34', ry); B.box(b[0], .2, b[1], 1.5, .4, .1, '#3d3a36', ry); - var ox = b[2] ? .24 : 0, oz = b[2] ? 0 : .24; B.box(b[0] + ox, .72, b[1] + oz, 1.8, .34, .07, '#8a5a34', ry); }); + TREES.forEach(function (t, n) { tree(B, t[0], t[1], t[2], n + 1, t[1] > 16); }); + // beyond the walls: a ring of trees and low hills so the horizon is not empty + for (k = 0; k < 40; k++) { var ang = k / 40 * 6.283 + r() * .1, rad = 56 + r() * 30, tx = -2 + Math.cos(ang) * rad * .95, tz = 2 + Math.sin(ang) * rad * .8, ss = 2 + r() * 1.5; + if (Math.abs(tx) < 12 && tz > 24 && tz < 44) continue; + B.cyl(tx, 2 * ss, tz, .25 * ss, .4 * ss, 4 * ss, '#5a4634', 5); B.ball(tx, 5.2 * ss, tz, 2.7 * ss, 2.3 * ss, 2.7 * ss, CANOPY[k % CANOPY.length], 8); B.ball(tx + 1.6 * ss, 4.3 * ss, tz + .6 * ss, 1.8 * ss, 1.5 * ss, 1.8 * ss, CANOPY[(k + 2) % CANOPY.length], 7); } + for (k = 0; k < 9; k++) { var ha = k / 9 * 6.283 + 0.3; B.ball(Math.cos(ha) * 190, -8, Math.sin(ha) * 170, 80 + r() * 40, 26 + r() * 14, 60 + r() * 30, k % 2 ? '#7f9552' : '#8a9a58', 10); } + BENCHES.forEach(function (b) { bench(B, b[0], b[1], b[2]); }); + house(B, glowB); // fountain and pond - B.cyl(FOUNTAIN.x, .28, FOUNTAIN.z, FOUNTAIN.r, FOUNTAIN.r + .1, .56, '#bdb5a4', 20); B.cyl(FOUNTAIN.x, .9, FOUNTAIN.z, .22, .34, 1.3, '#aaa293', 10); B.cyl(FOUNTAIN.x, 1.55, FOUNTAIN.z, .8, .3, .16, '#bdb5a4', 14); - B.cyl(POND.x, .16, POND.z, POND.r, POND.r + .12, .32, '#a9a294', 26); - var water = new THREE.MeshLambertMaterial({ color: 0x3f7f8c, emissive: 0x16323a }); - var w1 = new THREE.Mesh(new THREE.CircleGeometry(FOUNTAIN.r - .22, 20), water); w1.rotation.x = -Math.PI / 2; w1.position.set(FOUNTAIN.x, .5, FOUNTAIN.z); scene.add(w1); - var w2 = new THREE.Mesh(new THREE.CircleGeometry(POND.r - .25, 26), water); w2.rotation.x = -Math.PI / 2; w2.position.set(POND.x, .27, POND.z); scene.add(w2); - for (k = 0; k < 14; k++) { var pa = r() * 6.28, pr = r() * (POND.r - .9); B.cyl(POND.x + Math.cos(pa) * pr, .285, POND.z + Math.sin(pa) * pr, .28 + r() * .2, .28, .02, '#4f8a3a', 9); if (k % 3 === 0) B.blob(POND.x + Math.cos(pa) * pr, .36, POND.z + Math.sin(pa) * pr, .13, '#f0a8c0', 1, k + 9); } + var F = FOUNTAIN, Pd = POND, stone = '#c2baa9'; + B.cyl(F.x, .26, F.z, F.r, F.r + .08, .52, stone, 30); B.cyl(F.x, .55, F.z, F.r + .07, F.r + .07, .08, '#d2cabb', 30); + B.cyl(F.x, .85, F.z, .2, .36, 1.1, '#b3ab9b', 14); B.cyl(F.x, 1.48, F.z, .86, .26, .2, stone, 20); B.cyl(F.x, 1.6, F.z, .9, .9, .05, '#d2cabb', 20); B.ball(F.x, 1.78, F.z, .16, .2, .16, '#b3ab9b', 9); + B.cyl(Pd.x, .16, Pd.z, Pd.r, Pd.r + .12, .32, '#b0a898', 30); B.cyl(Pd.x, .34, Pd.z, Pd.r + .1, Pd.r + .1, .06, '#c7bfae', 30); + var water = new THREE.MeshLambertMaterial({ color: lin('#4d8e9c'), emissive: lin('#1c3d45') }); + var w1 = new THREE.Mesh(new THREE.CircleGeometry(F.r - .12, 28), water); w1.rotation.x = -Math.PI / 2; w1.position.set(F.x, .46, F.z); scene.add(w1); + var w2 = new THREE.Mesh(new THREE.CircleGeometry(Pd.r - .1, 28), water); w2.rotation.x = -Math.PI / 2; w2.position.set(Pd.x, .27, Pd.z); scene.add(w2); + for (k = 0; k < 14; k++) { var pa = r() * 6.28, pr = r() * (Pd.r - .9); B.cyl(Pd.x + Math.cos(pa) * pr, .285, Pd.z + Math.sin(pa) * pr, .28 + r() * .2, .28, .02, '#4f8a3a', 9); if (k % 3 === 0) B.ball(Pd.x + Math.cos(pa) * pr, .36, Pd.z + Math.sin(pa) * pr, .12, .09, .12, '#f0a8c0', 7); } // glasshouses: white frames, plants inside, glass as a second mesh var glassB = new Builder(); GLASS.forEach(function (g, n) { @@ -297,14 +394,14 @@ glassB.box(cx, 1.5, cz, w - .1, 1.9, d - .1, '#cfe9ee'); var rl = Math.sqrt(w * w / 4 + 1), ra = Math.atan2(1, w / 2), g1 = new THREE.BoxGeometry(rl, .04, d); g1.rotateZ(ra); glassB.add(g1, '#cfe9ee', cx - w / 4, 2.95, cz); var g2 = new THREE.BoxGeometry(rl, .04, d); g2.rotateZ(-ra); glassB.add(g2, '#cfe9ee', cx + w / 4, 2.95, cz); - for (var q = 0; q < 9; q++) B.blob(g[0] + 1 + r() * (w - 2), .9 + r() * .5, g[2] + 1 + r() * (d - 2), .5 + r() * .5, ['#3f7d3a', '#5a9a45', '#2f6a3a', '#7fae4a'][q % 4], 1.2, q + n * 20 + 300); + for (var q = 0; q < 9; q++) { var br = .5 + r() * .5; B.ball(g[0] + 1 + r() * (w - 2), .9 + r() * .5, g[2] + 1 + r() * (d - 2), br, br * 1.2, br, ['#3f7d3a', '#5a9a45', '#2f6a3a', '#7fae4a'][q % 4], 8); } }); - var glass = glassB.mesh(new THREE.MeshLambertMaterial({ vertexColors: true, transparent: true, opacity: .26, depthWrite: false })); scene.add(glass); - // potting shed by the start - var shx = (SHED[0] + SHED[1]) / 2, shz = (SHED[2] + SHED[3]) / 2; B.box(shx, 1.15, shz, 3, 2.3, 1.6, '#7c8f6a'); B.box(shx, 2.45, shz, 3.4, .22, 2.1, '#4b3a2c'); B.box(shx - .7, 1.0, SHED[2] - .02, .9, 1.9, .06, '#5a4532'); B.box(shx + .8, 1.5, SHED[2] - .02, .8, .7, .05, '#d9ecf0'); + scene.add(glassB.mesh(new THREE.MeshLambertMaterial({ vertexColors: true, transparent: true, opacity: .26, depthWrite: false }))); + // potting shed in the court + var shx = (SHED[0] + SHED[1]) / 2, shz = (SHED[2] + SHED[3]) / 2; B.box(shx, 1.15, shz, 3, 2.3, 1.6, '#7c8f6a'); B.box(shx, 2.45, shz, 3.4, .22, 2.1, '#4b3a2c'); B.box(shx - .7, 1.0, SHED[2] - .02, .9, 1.9, .06, '#5a4532'); glowB.box(shx + .8, 1.5, SHED[2] - .02, .8, .7, .05, '#d9ecf0'); // lamp posts [[-11, 1], [11, 1], [-2.6, -1.2], [2.6, -1.2], [13.2, 12.6], [13.2, -12.6], [-13.2, -12.4], [35, 19], [35, -29], [-39, -29], [-39, 19], [-11, -29], [11, -29]].forEach(function (l) { - B.cyl(l[0] * S, 1.5, l[1] * S, .05, .08, 3, '#2f2f33', 6); B.blob(l[0] * S, 3.1, l[1] * S, .2, '#fff1c4', 1, 3); + B.cyl(l[0] * S, 1.5, l[1] * S, .05, .08, 3, '#2f2f33', 6); B.box(l[0] * S, 3.02, l[1] * S, .3, .04, .3, '#2f2f33'); glowB.ball(l[0] * S, 3.2, l[1] * S, .16, .2, .16, '#fff1c4', 8); B.box(l[0] * S, 3.42, l[1] * S, .34, .05, .34, '#2f2f33'); }); // chutes: a dark grate with a painted border WR.CHUTES.forEach(function (c) { @@ -315,37 +412,37 @@ // bins: a slatted compost crate with a flag; the leaf heap inside is its own mesh so it can grow WR.BINS.forEach(function (b, n) { [[-.66, 0, .08, 1.4], [.66, 0, .08, 1.4], [0, -.66, 1.4, .08], [0, .66, 1.4, .08]].forEach(function (s) { for (var q = 0; q < 3; q++) B.box(b.x + s[0], .2 + q * .34, b.z + s[1], s[2], .26, s[3], q % 2 ? '#a9743f' : '#96653a'); }); - [[-.66, -.66], [.66, -.66], [-.66, .66], [.66, .66]].forEach(function (s) { B.box(b.x + s[0], .58, b.z + s[1], .12, 1.16, .12, '#6f4a2a'); }); - B.cyl(b.x + .66, 1.9, b.z + .66, .03, .03, 1.6, '#6f4a2a', 5); B.box(b.x + .66 + .25, 2.5, b.z + .66, .5, .3, .03, '#e2572f'); - var heap = new Builder().blob(0, 0, 0, .62, '#a8672b', .7, n + 40).mesh(); heap.position.set(b.x, .2, b.z); heap.scale.y = .3; scene.add(heap); + [[-.66, -.66], [.66, -.66], [-.66, .66], [.66, .66]].forEach(function (s) { B.box(b.x + s[0], .6, b.z + s[1], .13, 1.2, .13, '#6f4a2a'); B.box(b.x + s[0], 1.22, b.z + s[1], .17, .05, .17, '#5a3c22'); }); + B.cyl(b.x + .66, 1.95, b.z + .66, .03, .03, 1.5, '#6f4a2a', 5); B.box(b.x + .66 + .19, 2.5, b.z + .66 - .19, .54, .32, .03, '#e2572f', Math.PI / 4); + var hb = new Builder(); hb.ball(0, 0, 0, .6, .5, .6, '#a8672b', 10); hb.ball(.2, .1, -.15, .35, .3, .35, '#c8822c', 8); hb.ball(-.22, .08, .18, .32, .28, .32, '#b8552a', 8); + var heap = hb.mesh(); heap.position.set(b.x, .2, b.z); heap.scale.y = .3; scene.add(heap); out.bins.push({ def: b, heap: heap }); }); - var props = B.mesh(); props.castShadow = props.receiveShadow = true; scene.add(props); - // tree blob shadows, shown when real shadows are off - var blobG = new THREE.CircleGeometry(1, 30), blobM = new THREE.MeshBasicMaterial({ color: 0x1c1a10, transparent: true, opacity: .2, depthWrite: false }); - out.blobs = new THREE.Group(); TREES.forEach(function (t) { var m = new THREE.Mesh(blobG, blobM); m.rotation.x = -Math.PI / 2; m.position.set(t[0] + .8, .02, t[1] - .5); m.scale.set(3 * t[2], 2.4 * t[2], 1); out.blobs.add(m); }); scene.add(out.blobs); + var props = B.mesh(new THREE.MeshLambertMaterial({ vertexColors: true, side: THREE.DoubleSide })); props.castShadow = props.receiveShadow = true; scene.add(props); + scene.add(glowB.mesh(new THREE.MeshBasicMaterial({ vertexColors: true, toneMapped: false }))); + // soft dark patches under the trees, for the setting without real shadows + var bc = document.createElement('canvas'); bc.width = bc.height = 64; var bg2 = bc.getContext('2d'), bgr = bg2.createRadialGradient(32, 32, 4, 32, 32, 32); bgr.addColorStop(0, 'rgba(20,16,8,.5)'); bgr.addColorStop(1, 'rgba(20,16,8,0)'); bg2.fillStyle = bgr; bg2.fillRect(0, 0, 64, 64); + var blobG = new THREE.PlaneGeometry(2, 2), blobM = new THREE.MeshBasicMaterial({ map: new THREE.CanvasTexture(bc), transparent: true, depthWrite: false }); + out.blobs = new THREE.Group(); TREES.forEach(function (t) { var m = new THREE.Mesh(blobG, blobM); m.rotation.x = -Math.PI / 2; m.position.set(t[0] + 1.1 * t[2], .021, t[1] - .9 * t[2]); m.scale.set(3.4 * t[2], 2.8 * t[2], 1); out.blobs.add(m); }); scene.add(out.blobs); // gates: two slatted leaves that swing open, and a sign over each WR.GATES.forEach(function (g) { var grp = new THREE.Group(), leaves = []; [-1, 1].forEach(function (side) { - var gb = new Builder(); for (var q = 0; q < 5; q++) gb.box(side * -(0.16 + q * .29), 1.0, 0, .2, 1.9 + (q === 4 ? .2 : 0), .07, q % 2 ? '#3f6b52' : '#386049'); gb.box(side * -.72, .5, .05, 1.4, .1, .05, '#2c4a3a'); gb.box(side * -.72, 1.6, .05, 1.4, .1, .05, '#2c4a3a'); + var gb = new Builder(); for (var q = 0; q < 5; q++) gb.box(side * -(0.16 + q * .29), 0.92 + q * 0.035, 0, .2, 1.7 + q * 0.07, .06, q % 2 ? '#3f6b52' : '#386049'); gb.box(side * -.72, .45, .05, 1.4, .1, .05, '#2c4a3a'); gb.box(side * -.72, 1.45, .05, 1.4, .1, .05, '#2c4a3a'); var m = gb.mesh(); m.castShadow = true; var piv = new THREE.Group(); piv.position.x = side * 1.5; piv.add(m); grp.add(piv); leaves.push({ piv: piv, side: side }); }); - var a = WR.AREAS[g.area], sign = new THREE.Mesh(new THREE.PlaneGeometry(2.2, 2.2), new THREE.MeshBasicMaterial({ transparent: true })); sign.position.set(0, 2.75, .02); grp.add(sign); + var sign = new THREE.Mesh(new THREE.PlaneGeometry(2.2, 2.2), new THREE.MeshBasicMaterial({ transparent: true })); sign.position.set(0, 2.75, .02); grp.add(sign); var back = new THREE.Mesh(sign.geometry, sign.material); back.position.set(0, 2.75, -.02); back.rotation.y = Math.PI; grp.add(back); // readable from both sides grp.position.set(g.x, 0, g.z); if (g.axis === 'z') grp.rotation.y = Math.PI / 2; scene.add(grp); - out.gates.push({ def: g, leaves: leaves, sign: sign, open: 0, target: 0 }); + out.gates.push({ def: g, leaves: leaves, sign: sign, back: back, open: 0, target: 0 }); }); + // a gate's sign only shows once the garden on this side of it is open (a new player sees no names or prices) out.refreshSigns = function (state) { - out.gates.forEach(function (G) { var a = WR.AREAS[G.def.area], un = state && state.unlocked[G.def.area]; + out.gates.forEach(function (G) { var ar = G.def.area, a = WR.AREAS[ar], un = state && state.unlocked[ar], from = ar === 0 ? -1 : ar <= 2 ? 0 : 1; + var show = !!state && from >= 0 && !!state.unlocked[from]; G.sign.visible = G.back.visible = show; if (!show) return; if (G.sign.material.map) G.sign.material.map.dispose(); G.sign.material.map = signTexture([T(a.name), un ? '' : T('Locked') + ' · ' + a.cost]); G.sign.material.needsUpdate = true; }); }; - // light: a low warm sun, soft sky fill - var hemi = new THREE.HemisphereLight(0xcfe0ee, 0x7a6a48, 0.62); scene.add(hemi); - var dir = new THREE.DirectionalLight(0xffe0b0, 0.78); dir.position.set(-38, 46, 44); dir.target.position.set(-1.6, 0, -4); scene.add(dir); scene.add(dir.target); - var cam = dir.shadow.camera; cam.left = -42; cam.right = 42; cam.top = 38; cam.bottom = -38; cam.near = 5; cam.far = 150; dir.shadow.mapSize.set(2048, 2048); dir.shadow.bias = -0.0012; - out.sun = dir; out.sunDir = dir.position.clone().sub(dir.target.position).normalize(); return out; }; })(); diff --git a/e63334287a3deaa3/windrow/preview.jpg b/e63334287a3deaa3/windrow/preview.jpg index 9228173f..0fb9c921 100644 Binary files a/e63334287a3deaa3/windrow/preview.jpg and b/e63334287a3deaa3/windrow/preview.jpg differ