diff --git a/README.md b/README.md index 5ca67867..e1aefaf9 100644 --- a/README.md +++ b/README.md @@ -33,7 +33,7 @@ Personal site hosted with GitHub Pages at **https://ascoding11.github.io**, the **Modes (November 2026): Duos, Trios, Creative, Box Fights and Zone Wars.** Five more ways to play with friends, made of Driftfall's own island, land shader, build pieces, editing, weapons, props and bots; Classic is the battle royale above, unchanged. **Picking one:** the menu has a Mode picker (Classic, Duos, Trios, Creative, Box Fights, Zone Wars, with the mode's options under it: Box Fights' team size 1v1 to 4v4, rounds to win 3, 5 or 7, bots fill in or off; Duos and Trios have only Bots, set in the lobby); Practice (offline) plays the picked mode against practice bots, and a room you make starts in it. In a room the host (the usual host: the longest-present live player) picks the mode and its options in the lobby, and everyone sees the pick; the host presses Start (modes have no countdown, and can start with one person when bots fill in; Creative always can). Quick match rooms (`dz-pub-…`) are always Classic. The pause panel gives the host End for everyone (back to the lobby). Saved in the browser: `driftfall:mode` (the menu's pick) and `driftfall:opts:`, and Creative's loadout `driftfall:crload` and rarity `driftfall:crrar`. **Arenas:** a mode is played on its own arena, which takes the island's place while it is on (`setArena`): its own height grid in `TH` (so `terrainH`, walking, shots, builds, the land rules, bots' paths and both maps follow it unchanged), its own ground and sea meshes on the island's ground shader with its own control map (`arenaCtl`: paving with the shader's joints on the 4 m build grid, dirt tracks, darker marks), the island's trees, rocks, bushes and grass tufts (one mesh each, solid but unbreakable, in the arena's hash only), and an empty spatial hash, so none of the island's buildings, chests or pieces are there. The island's hash, ramps, heights, ground, sea, bots' grid and map picture are kept aside and put back exactly when the mode ends (`ISL`); an arena is made the first time it is needed and kept (`ARC`). Creative: a 128 m paved square at 4 m, a grassy rim with two hills, a beach. Box Fights: a flat paved circle with a fixed edge 24 m out (drawn as a low bank of the storm's cloud; nobody walks or builds past it), the two teams' boxes 8 m apart. Zone Wars: a round island about 140 m across with rolling ground and five hills (all under 15 m), rocks, pines and dirt tracks. **Creative:** unlimited scrap and ammo (∞ on the HUD), no storm, fly (the Fly key, Y, or Jump twice; Jump goes up and Fly down, Shift, goes down; on a phone FLY and DOWN buttons above the stick), Back to spawn (U), a knockout puts you back where you fell after 3 s, health and shield come back after 4 s out of a fight. Creative tools (I, or Creative tools in the pause panel): your four slots from every weapon and heal at any rarity, practice targets (stand-still bots, up to 12, put 6 m in front of you; knocked out, one stands again 2 s later), sparring bots (up to 4, put 14 m in front of you, with Box Fights' loadout and a mode bot's mind, so they come for whoever is near; knocked out, one comes back where it was put 3 s later; `pracArm`), Clear them all, Clear my builds and, for the host, Clear every build. Anyone may edit any build, and everyone in the room is in it whenever they join. **Box Fights:** two teams, Blue and Orange (colours always with the name), each starting in its own one-cell box of real build pieces (four walls, a floor and a roof, owned by the team, `T0`/`T1`: the team's to edit, anyone's to break), with a fixed loadout every round (Epic Pump Shotgun, SMG and Rifle, 3 Shield Fizz, 200 scrap, full shield); a 4 s countdown (3, 2, 1, FIGHT) with everyone frozen; no damage from team-mates (shots pass through them); last team standing takes the round, or after 2:30 the team with more health and shield left (a tie is nobody's); first to N. Team-mates are on the map and name tags are in the team's colour; a knocked-out player watches a team-mate. **Zone Wars:** everyone for themselves on random spots (`zwSpawns`) with a fixed loadout (Rare Pump Shotgun, Rifle and Drum SMG, 2 Shield Fizz, 300 scrap, 50 shield) and a fast storm (`ZW_PH`: six phases, closed in under two minutes) whose next circle jumps from a third of the way to nearly the edge of the last one, so part of it is often outside the old circle; last one standing takes the round (if the storm takes the last two together, nobody does); first to N. **Bots:** Box Fights fills each team, Zone Wars fills up to 8 (on by default, off in the options; Practice always fills). They use `botThinkM`: no loot, go for the nearest enemy (never a team-mate or a target), shoot through and break builds in the way, stay out of the storm. **Sync:** the host decides everything and puts it in its node. A mode's match state goes in a new key, `mx` (`md` the mode, `op` its options, and per round `rn` the round, `sc` the score as a string, `blue-orange` or `id:wins,…`, `tm` each roster place's team, `zs` Zone Wars' circles as `x,z,r;…`, `sid` the series, `rw` the round's winner, `fin`/`wn` at the end), while `ms` then just says lobby: pages from before the modes only read `ms`, so they sit a mode out in the lobby instead of playing it on the island, and Classic's `ms` is exactly what it was. Every page writes `gm: 1`, and only pages with it are put in a mode's roster (the lobby says how many people have an older copy). Each round is a match of its own (a new id), so `setupMatch` puts the arena, builds and everyone back between rounds and events from an old round are dropped; the boxes are built the same way on every page at a round's start, and someone arriving mid-round gets the builds as they stand from the host's build list (`bd`, whose owner field now also says 61/62 for a team's box). The host runs the bots and targets and lists them in its node (`bt`: `{id: [x, y, z, heading, pitch, health, shield, state, in hand, knockouts, 1 target / 2 sparring bot / 0, 1 down]}`), which the others draw with `netsmooth.js` like players; a bot's shots, builds and knockouts are the host's events marked `f` (the bot's id), which pages from before ignore; hits on a bot are sent to the host, as hits on a player go to that player. If the host leaves, the next one runs the bots from where they are (`takeBots`) and carries on the round and the score from the last `mx` it saw. Creative's commands (clear my builds, clear every build, add a target or a sparring bot, `fi: 1`, clear them) are events `k: 'cm'`; the host adds everyone who arrives to Creative's roster (only ever added to, so builds keep their owners in the build list). No Firebase paths or rules changed. **Stats:** the modes (Duos and Trios too) record nothing in the Leaderboards (no matches, wins, knockouts, placings or Elo; `recordStats` returns at once), so Driftfall's battle-royale boards and the miles worked from them only ever count Classic (solo). Play time is still counted by stats.js, as for any game, because it is time spent playing Driftfall. A separate set of keys would show nowhere (leaderboard.js lists only Driftfall's Classic stats) and only make every player's stats node bigger. **Cost:** an arena is one ground and one sea mesh in place of the island's, one props mesh and one tufts mesh (Creative measured 12 draw calls on the plain look); making one the first time takes a moment (its ground, sea, map and bots' grid). Nothing new is made every frame except the HUD's strings a few times a second. **Duos and Trios (`du`, `tr`):** the battle royale in teams of 2 or 3, on the island with the Drifter, loot and storm exactly as in Classic: in the code `GM` stays `'br'` and `SQ` is the team size, so everything Classic does is shared (see "Squads" in the script). Teams (`tm`, one base-36 digit per roster place) are the people in the order they joined the room (a Party that launches together joins together), filled with bots when Bots is on, plus bot teams up to 12 players (`sqRoster`); Practice is you and your bot team-mates against bot teams (6 teams of 2, 4 of 3). Online, as in Box Fights, the host runs the bots (`bt`, now also with the Drifter, falling and gliding states) and sends their shots, loot and knockouts as events marked `f`; a team's bots jump just after their person and land near them, and catch up with them when they fall 24 m behind. **No friendly fire:** shots pass through team-mates and a team-mate's hit is never applied. **Name tags:** team-mates' tags are blue and show through anything from anywhere; team-mates are blue dots on both maps; a dead player watches a team-mate. **Down, not out:** when your health runs out while someone on your team is still up, you go down instead (`dn: 1` in your node; event `k: 'dn'`): 100 health that bleeds away at 3.4 a second, crawling at a third of the speed, lying face down (lower hit boxes, a lower camera), no shooting, building, editing, opening or healing (on a phone Fire, Aim, Reload and Edit hide). A team-mate holding Use (G, or the touch button, which reads REVIVE) within 2.4 m for 4 s picks you up with 30 health (event `k: 'rv'`); bots go to a downed team-mate within 45 m and do the same, and a downed bot crawls to its nearest team-mate. Anyone else's shots, the storm or bleeding out finish you, and once nobody on the team is up everyone down on it is out. As with every hit, each browser decides this for its own player (and the host for its bots). **Winning:** the last team with anyone left (`wt` in the match state); the HUD counts teams left, the end panel shows the team's place out of the teams. The match state is in `mx`, like the other modes, so a page from before sits a Duos or Trios match out. **Tests** (`window.__dz`, webdriver only) add `GM`, `SQ`, `arenaOn`, `setArena`, `modeStart`, `botNet`, `syncBots`, `sqRoster`, `goDown`, `sqUp` and the rest of the mode functions. **Checked** in Practice for every mode (rounds, scores, boxes put back, the storm, flying, tools, targets and sparring bots, downs, revives by you and by bots, team wipes, a team win) and online with two browsers in one room for Creative (shared builds, a sparring bot, clearing), Box Fights 1v1 (a round won, the next one set up), Zone Wars (the same circles on both) and Duos (both on one team with 10 host-run bots, no friendly fire, a down seen by the team-mate and a revive by them, a host bot downed by the other player), at 1280 × 800, 375 × 812 and 812 × 375 with no console errors. Weak or not checked: Trios online, 3v3 and 4v4 Box Fights online, a host leaving mid-match in a mode (the bots carry on with the next host from where they are, with a basic loadout in Duos and Trios), a full room of 30, and a real phone; you can't pick your team (it's join order); downed players' lying pose is the falling pose on the ground. Collision rules (keep them if you touch movement): you and the Entity are boxes 0.72 m wide and 1.95 m tall; map walls, posts, pillars (0.9 m and 1.5 m), office partitions (1.25 m tall, 12 cm thick: jump onto or over them) and built walls and floors are solid boxes. A ramp is solid too (`inRamp`): a sloping sheet 0.33 m thick whose top you walk on. With the middle of a body over a ramp, the body is clear of it only on top (feet no more than a 0.6 m step below the surface, which is how you step onto the low end or land on it from a jump) or underneath with its head under the ramp's underside; anything between counts as inside the ramp, and movement never goes there: walking or jumping into a ramp from the side or from behind stops you (`rampBlocks`), under one you can only stand where there is head room (the 1.5 m under the high end) and a jump there stops at the underside, and nothing gets up through a ramp from below. (Until November 2026 ramps were walkable surfaces only and could be walked and jumped through.) Movement goes one axis at a time so you slide along walls; a move that would enter a solid is dropped unless it is a step of up to 0.6 m onto something with head room; and a frame that would move you more than 0.25 m (below about 25 fps; frames are capped at 50 ms) is split into shorter steps, so nothing as thin as a wall can be skipped over. You stand on anything your box overlaps and fall only once you are clear of it, and walking up a ramp into a floor stops you under it (if a floor dropped on you pushed you down below a ramp's surface, you can still walk back down the ramp, just not further up). The only way into a solid is a build landing on you (your own, the Entity's or another player's), and the game then shoves you out the shortest way (sideways out of a wall, up onto or down from under a floor) that ends inside the map without passing through any other wall or build on the way, rather than trapping you or letting you walk through it; the same push-out runs at spawn and on every step. A ramp that lands on you (`rampOut`) lifts you onto it if that is no more than 2 m up, so a ramp placed in the cell you are standing in puts you on it ready to climb; otherwise you are moved the shortest free way: along the slope to where there is head room underneath or to where it is low enough to step onto, out of a side, or up or down. Other players' drawn positions are clamped to the map and pushed out of solid boxes too (not ramps: each player's own page keeps them out of those), so a corner cut between two updates, or a late update carried on, never draws (or lets you shoot) someone inside a wall. Shots are rays tested against every solid, ramp surface, the floor and the ceiling before players, so they can't pass through walls or builds. - `e63334287a3deaa3/blockstorm/`: Blockstorm (Back Room), a blocky first-person shooter by GitHub user **dessyc9** (the original is at dessyc9.github.io/blockstorm), ported here with their permission. The fight is on the roofs of five sky towers above an endless city in rain and lightning, joined by eight glass maze bridges; a shove (F) can push someone off the edge. Free-for-all (most kills when the clock runs out) or capture the flag (Blue vs Red, two flags each, first to 3 captures). Everyone starts a match with the same Common guns and kills unlock the next rarity (`TIER_KILLS`: Rare at 5, Epic 10, Legendary 20, Mythic 30); a storm core on the middle tower gives a full shield and +30% damage for 15 s. The Shop (all free, new guns every day from a seeded generator) and Loadouts are the original game's and are saved in this browser only (`blockstorm_profile`); they don't change the guns used in matches. **What changed in the port:** the original's online play went through public MQTT relays (HiveMQ and EMQX, with mqtt.js from jsdelivr), a lobby hub and an "online now" list on those relays, and an owner account (a password-derived signing key, a crown, a kick button and top-tier guns for the owner). All of that is gone: online play uses the site's Firebase rooms, names come from the game's own name box (`blockstorm:name`, filled by party.js; it starts from `ol:name` or `party:name` if there is none), and the Back Room's Online, Party and Playing now panels do what the hub did. three.js is the original's r160 ES module, now from cdnjs (`three.module.min.js`): a small module puts it on `window.THREE` as a plain object, then `../autores.js` (deferred, so it runs after that module and before the game's module) wraps `THREE.WebGLRenderer` as in the other 3D games; moving the game to r128 would have meant retuning all its lighting and colours. **Online:** rooms under `rooms/bs-` in the Firebase Realtime Database (same project and rules as the other games), up to 12 people (`MAX_PLAYERS`), invite links `#bs-`. Quick match uses the public lobbies `bs-pub-1` to `4` (free-for-all) and `bs-ctf-pub-1` and `2` (capture the flag), which start by themselves with 9 medium bots, run 5 minutes and start the next match 12 s after one ends; any other code is a private room where the host picks the mode and bots (none, medium, hard, extreme) in the lobby and presses Start. The shared rules only let a browser write its own node and expect `n, c, x, z, h, ts`, so everything is in `players/`: `n` name, `c` shirt colour, `x y z h p` position, yaw and pitch, `w` gun slot, `sc` shots fired, `lf` life number, `a` alive, `m` match, `lk` look seed, `j` join time, `v` format (1), and `ev/e0`…`ev/e31`, a ring of events with a number `i` that only goes up (`h` a hit you landed, added up per target per update, `sv` a shove, `pj` a launcher shot; from the host `kl` a kill, `hu` you were hurt, `hm` your hit killed, `kn` knockback, `bo` storm core, `ct`/`nt` feed lines). The host is the live player with the smallest `j` (a tab that was frozen for 5 s goes to the back of the line); its browser runs the match exactly as the original's host did (bots, damage, kills, clock, flags, storm core, gun tiers) and also writes `rs` (the match: `id`, `st` lobby / play / end, `md` mode, `bl` bot level, `nb` bots, `t0` start and `len` length rather than an end time, `et` when it ended), `ch` (one row per fighter: id, alive, health, shield, kills, deaths, spawn shield, best streak, team, tier, storm core, life, and where it last spawned, which is how a client is placed), `bm` (bots' names and looks), `bt` (bots' positions and shot counts), `cf` (flags and score) and `k` (storm core ready). Players send their own position about 12 times a second and the host its bots at the same rate; every fighter is drawn from those time-stamped updates with `netsmooth.js`, and others' shots are drawn from the `sc` counts. Each browser is trusted for its own position and hits, so it isn't cheat-proof. If the host leaves, the next in line takes over the match from the last state it heard, and its bots become that browser's to run; people who join mid-match take a bot's place. **Leaderboards:** play time through `stats.js`, and `kills`, `kdkills`, `deaths`, `mkills` (most in a match) and `wins` (online only, with at least one other real player in the match); the boards are in `leaderboard.js`. **Touch:** on touch screens a move stick, drag to look, Fire, Jump, Aim, Reload, Swap, Shove, pause and scoreboard buttons, and the gun slots at the top are tap targets; the health, gun and clock readouts move to the top so nothing sits under a thumb upright or sideways. The keyboard and mouse controls are the original's. A webdriver-only test hook is `window.__bs`. **Spanish** (lang.js): its words are in `blockstorm/es.js` (the menus are rebuilt as HTML and translated by lang.js as they appear); the flag and Storm Core lines the host sends to the room stay English on the wire and each page shows them in its own language, and gun, set, bot and loadout names stay as they are. -- `e63334287a3deaa3/sky-duel/`: Sky Duel (Back Room), an original arcade dogfighting game for up to 8 planes (three.js r128 with `../autores.js`; one self-contained `index.html`, everything drawn and synthesised in code). **Modes:** Duel (1v1), free-for-all and 2v2 (Blue vs Orange), first to the kill target (5 to 20) or most kills when the clock runs out; solo against bots, or online. **The map** is one height function (`terrainRaw`, whole-number hash noise so every browser builds the same land) sampled on a 150 × 150 grid over 6 km: green hills, lakes and sharp peaks in the west, a red-rock plateau cut by canyons in the east (`CANYONS` are the centre lines), a ring of mountains round it, and clouds you can fly through (the screen whites out inside one). `terrainH` reads the same two triangles per grid square that the mesh draws, so what you see is what you hit. Past `ARENA_R` a pilot gets 8 seconds to turn back. **Flight** (`stepPlane`) is deliberately simple: a plane is a heading, a pitch (kept within ±75°, so no loops) and a bank; it steers toward an aim direction at a turn rate that falls as speed rises, climbing costs speed, hard turns cost a little, and under `STALL` the nose drops until it has picked speed back up. Above `CEIL` the engine fades. Boost drains a meter; a barrel roll (0.8 s, 2.4 s cooldown) slides the plane sideways, makes half the bullets miss and usually shakes off a missile that is about to arrive. The ground, the water and the canyon walls are always fatal. All four planes (`PLANE_GEO`: Puffin, Swift, Heron, Dart) fly the same. **Weapons:** machine guns that overheat (`HEAT_UP` per shot, jammed until they cool to 35%), homing missiles that need the target held within `LOCK_CONE` of the nose for `LOCK_T` seconds (two to start, four at most, one back every 22 s), flares (a 70% chance to pull away each missile within `FLARE_R`), and rings to fly through (`PICKS`: green repairs 45 hull, orange two missiles, white two flares; back after 20 s). **HUD:** the ring is the aim, the amber cross is where the guns point, the diamond is the lead marker (where to shoot so the bullets meet the target); boxes with names, distance and hull on other planes, arrows for the ones off screen, a lock ring, a radar that turns with the plane, a kill feed and warnings (missile, stall, pull up, turn back, overheated). **Bots** (`botThink`, levels in `DIFF`: Rookie, Veteran, Ace) fly the same plane through the same controls: each frame a bot only chooses where to aim, the throttle and which buttons to press; `avoidGround` looks up to 2.6 s ahead and pulls up or turns toward lower ground. **Controls:** the mouse aims and the plane follows (pointer lock), with rebindable keys through `keybinds.js` (saved as `keybinds:sky-duel`; the arrow keys and A/D steer without a mouse); on touch screens a stick, a throttle slider and Roll, Flare, Missile, Boost and Fire buttons, with the radar, feed and score moved so nothing overlaps upright or sideways. **Online:** rooms under `rooms/vq-` in the Firebase Realtime Database (same project and rules as the other games), up to 8 people (`MAX_ROOM`), invite links `#vq-`. Quick match uses the public rooms `vq-pub-1` to `4`, which run free-for-alls by themselves (to 15 kills or 5 minutes, Veteran bots filling to 6, the next match 12 s after one ends); any other code is a private room with a briefing room where the host picks the mode, kill target, time, bots and bot level and presses Take off. A duel is for two pilots and 2v2 for four: with more people in the room the host's choice becomes a free-for-all, and someone who joins a full duel or 2v2 watches until the next match. The shared rules only let a browser write its own node and expect `n, c, x, z, h, ts`, so everything is in `players/`: `n` name, `c` colour, `fr` plane, `x y z` position, `h p r` heading, pitch and bank, `s` speed, `f` flags (1 firing, 2 boosting, 4 rolling, 8 alive, 16 spawn shield, 32 sitting out), `hp`, `k` kills, `d` deaths, `j` join time, `v` format (1), and `ev/e0`…`ev/e31`, a ring of events with a number `i` that only goes up (`h` hits one of your planes landed, added up per target every 0.1 s; `k` one of your planes died, and who gets the credit; `m` a missile launched, `c` it lost its target, `x` it blew up; `f` a flare; `p` a ring taken). The host is the live player with the smallest `j` (a tab that is hidden while hosting moves itself to the back of the line); its node also carries `rs` (the match: `id`, `st` 0 briefing / 1 flying / 2 over, `md` mode, `kl`, `tl`, `lvl`, `fill`, `t0` start time, `sky`, `tm` who is on which team, `bl` which bot seats are in use, `rev`, `et`, `win`) and `bt` (each bot's position, flags, hull and score). Nodes are sent 10 times a second and every other plane is drawn from those time-stamped updates with `netsmooth.js`. Each browser decides the hits of its own bullets and missiles against where it sees the other planes, the browser that owns the plane hit takes the damage and announces the kill, and the killer's own browser adds the kill to its score, so nobody writes anyone else's data (and it isn't cheat-proof). If the host leaves, the next in line carries on from the last `rs` it heard and flies the bots from where they were; a newcomer takes a bot's seat and a bot takes the seat of someone who left (`fixRoster`). Solo and the dogfight behind the menu run the same code with this browser as the host. **Saved in this browser:** `skyduel-name`, `-color`, `-frame`, settings and the last room. **Leaderboards:** play time through `stats.js`, and `kills`, `kdkills`, `deaths` (solo and online), `mkills` (most in a match) and `wins` (online only, with at least one other person flying); the boards are in `leaderboard.js`. Graphics has Pretty and Fast (sharpness and particle counts at once, trees and clouds on the next load); phones start on Fast. `AD_SLOT` is empty. A webdriver-only test hook is `window.__skd`. **Spanish** (lang.js): its words are in `sky-duel/es.js`, banners, warnings, the lock ring and the scores go through `TX()` (those HUD parts are `data-noi18n`), and plane names and bot callsigns stay as they are. +- `e63334287a3deaa3/sky-duel/`: Sky Duel (Back Room), an original arcade dogfighting game for up to 8 planes (three.js r128 with `../autores.js`; one self-contained `index.html`, everything drawn and synthesised in code). **Modes:** Duel (1v1), free-for-all and 2v2 (Blue vs Orange), first to the kill target (5 to 20) or most kills when the clock runs out; solo against bots, or online. **The map** is one height function (`terrainRaw`, whole-number hash noise so every browser builds the same land) sampled on a 150 × 150 grid over 6 km: green hills, lakes and sharp peaks in the west, a red-rock plateau cut by canyons in the east (`CANYONS` are the centre lines), a ring of mountains round it, and clouds you can fly through (the screen whites out inside one). `terrainH` reads the same two triangles per grid square that the mesh draws, so what you see is what you hit. Past `ARENA_R` a pilot gets 8 seconds to turn back. **Flight** (`stepPlane`) is deliberately simple: a plane is a heading, a pitch (kept within ±75°, so no loops) and a bank; it steers toward an aim direction at a turn rate that falls as speed rises, climbing costs speed, hard turns cost a little, and under `STALL` the nose drops until it has picked speed back up. Above `CEIL` the engine fades. Boost drains a meter; a barrel roll (0.8 s, 2.4 s cooldown) slides the plane sideways, makes half the bullets miss and usually shakes off a missile that is about to arrive. The ground, the water and the canyon walls are always fatal. All four planes (`PLANE_GEO`: Puffin, Swift, Heron, Dart) fly the same. They are drawn at `PLANE_SIZE` (1.15 × 1.12, made 12% bigger in November 2026), and the bullet hit sphere `HIT_R` (9 × 1.12 m) and the spawn shield grew with them, so what you see is what you hit; the hit of a bullet is decided only by the browser that fired it, so a page from before that change in the same room still agrees with everyone (its own bullets just use the old 9 m), and the missile fuse, the ground clearance and the camera are unchanged. **Weapons:** machine guns that overheat (`HEAT_UP` per shot, jammed until they cool to 35%), homing missiles that need the target held within `LOCK_CONE` of the nose for `LOCK_T` seconds (two to start, four at most, one back every 22 s), flares (a 70% chance to pull away each missile within `FLARE_R`), and rings to fly through (`PICKS`: green repairs 45 hull, orange two missiles, white two flares; back after 20 s). **HUD:** the ring is the aim, the amber cross is where the guns point, the diamond is the lead marker (where to shoot so the bullets meet the target); boxes with names, distance and hull on other planes, arrows for the ones off screen, a lock ring, a radar that turns with the plane, a kill feed and warnings (missile, stall, pull up, turn back, overheated). **Bots** (`botThink`, levels in `DIFF`: Rookie, Veteran, Ace) fly the same plane through the same controls: each frame a bot only chooses where to aim, the throttle and which buttons to press; `avoidGround` looks up to 2.6 s ahead and pulls up or turns toward lower ground. **Controls:** the mouse aims and the plane follows (pointer lock), with rebindable keys through `keybinds.js` (saved as `keybinds:sky-duel`; the arrow keys and A/D steer without a mouse); on touch screens a stick, a throttle slider and Roll, Flare, Missile, Boost and Fire buttons, with the radar, feed and score moved so nothing overlaps upright or sideways. **Online:** rooms under `rooms/vq-` in the Firebase Realtime Database (same project and rules as the other games), up to 8 people (`MAX_ROOM`), invite links `#vq-`. Quick match uses the public rooms `vq-pub-1` to `4`, which run free-for-alls by themselves (to 15 kills or 5 minutes, Veteran bots filling to 6, the next match 12 s after one ends); any other code is a private room with a briefing room where the host picks the mode, kill target, time, bots and bot level and presses Take off. A duel is for two pilots and 2v2 for four: with more people in the room the host's choice becomes a free-for-all, and someone who joins a full duel or 2v2 watches until the next match. The shared rules only let a browser write its own node and expect `n, c, x, z, h, ts`, so everything is in `players/`: `n` name, `c` colour, `fr` plane, `x y z` position, `h p r` heading, pitch and bank, `s` speed, `f` flags (1 firing, 2 boosting, 4 rolling, 8 alive, 16 spawn shield, 32 sitting out), `hp`, `k` kills, `d` deaths, `j` join time, `v` format (1), and `ev/e0`…`ev/e31`, a ring of events with a number `i` that only goes up (`h` hits one of your planes landed, added up per target every 0.1 s; `k` one of your planes died, and who gets the credit; `m` a missile launched, `c` it lost its target, `x` it blew up; `f` a flare; `p` a ring taken). The host is the live player with the smallest `j` (a tab that is hidden while hosting moves itself to the back of the line); its node also carries `rs` (the match: `id`, `st` 0 briefing / 1 flying / 2 over, `md` mode, `kl`, `tl`, `lvl`, `fill`, `t0` start time, `sky`, `tm` who is on which team, `bl` which bot seats are in use, `rev`, `et`, `win`) and `bt` (each bot's position, flags, hull and score). Nodes are sent 10 times a second and every other plane is drawn from those time-stamped updates with `netsmooth.js`. Each browser decides the hits of its own bullets and missiles against where it sees the other planes, the browser that owns the plane hit takes the damage and announces the kill, and the killer's own browser adds the kill to its score, so nobody writes anyone else's data (and it isn't cheat-proof). If the host leaves, the next in line carries on from the last `rs` it heard and flies the bots from where they were; a newcomer takes a bot's seat and a bot takes the seat of someone who left (`fixRoster`). Solo and the dogfight behind the menu run the same code with this browser as the host. **Saved in this browser:** `skyduel-name`, `-color`, `-frame`, settings and the last room. **Leaderboards:** play time through `stats.js`, and `kills`, `kdkills`, `deaths` (solo and online), `mkills` (most in a match) and `wins` (online only, with at least one other person flying); the boards are in `leaderboard.js`. **Ranked:** online matches move a rating through `../elo.js` (`rateMatch`, called from `endMatch`, once per match: `id` is the room and `rs.id`): you are rated against every opponent who was still flying at the end (bots count as 1000, teammates and pilots sitting out don't count), by the final standings in a free-for-all (more kills wins, then fewer losses, equal both is a draw) and by the result in a duel or 2v2. It is only rated with at least one other real person among those opponents, and only if you flew at least a minute of the match (`RANK_MIN`, from the start or from when you joined), or were there from the start of one that ended on the kill target (before its clock ran out); it waits 1.5 s (`RANK_SETTLE`) after the end for the last scores to arrive from the other browsers, redraws the standings with them, and the host's winner always counts as having beaten you; solo, the menu's dogfight, leaving early and watching never count. The end screen shows the new rating and the change (or why the match was unranked) under the standings, as well as elo.js's own pill, and the Elo board comes first among Sky Duel's boards. Graphics has Pretty and Fast (sharpness and particle counts at once, trees and clouds on the next load); phones start on Fast. Pretty draws at up to 1.5 pixels per CSS pixel and Fast at 1 (1.25 on phones); Fast also lights the water per vertex, without Pretty's sun glint. **Drawing:** every plane goes through instanced meshes (`PLANE_INST`: a body, whose instance colour is the plane's colour, and a trim per airframe, plus `PROP_INST` and `SHIELD_INST`), all missiles through `MSL_INST` and the twelve rings through `PICK_RING`/`PICK_CORE`, so `e.mesh`, `m.mesh` and `p.mesh` are plain `Object3D`s that only hold a position and rotation, and an instanced mesh with nothing in it is hidden; the sky dome is drawn after the solid things with the depth test on (`renderOrder` 1), so its shader only runs where the sky shows. The HUD only writes to the page when a value changes (`put`, `setOp`, `setBar`). `AD_SLOT` is empty. A webdriver-only test hook is `window.__skd`. **Spanish** (lang.js): its words are in `sky-duel/es.js`, banners, warnings, the lock ring and the scores go through `TX()` (those HUD parts are `data-noi18n`), and plane names and bot callsigns stay as they are. - `e63334287a3deaa3/spire/`: Spire (Back Room), an obby-style parkour race up a tower stacked from random sections (Three.js, Firebase Realtime Database rooms under `rooms/tw-…`, same project and rules as Rumble Karts; Quick match uses `rooms/tw-pub-1` to `tw-pub-4`; invite links go through the home page as `#tw-`; rooms hold up to 12). Everything that isn't drawing lives between the `// ==CORE==` and `// ==/CORE==` markers in the page: movement (`PHYS`, `simStep`), parts (upright boxes and cylinders, each optionally moving by `line`, `spin` or `orbit`, timed, crumbling, lethal, bouncy, a conveyor, a climbable truss, `ice` (on the ground you speed up at `ICE_ACC` and slow at `ICE_DEC`, so you slide), a launch pad (`boost`: landing or stepping on it sets your velocity to that vector, and the take-off speed that caps air control is measured again from it) or a wind zone (`zone: 'wind'` with a `wind` vector, usually timed: while it's on it carries you like a conveyor, in the air too)), the section library (`MODS`), towers (`buildTower`), the obby (`buildObby`, `WORLDS`) and the checking bot; it has no DOM or Three.js in it, so a test can run it on its own. Physics is a fixed 120 Hz step with the player as an upright cylinder; moving parts are placed by time alone, so every player who shares the round clock sees the same tower. A jump reaches 3.37 (3.67 counting the pop onto a ledge just above your feet) and you run at 7.5. In the air the stick only nudges you (`airControl`): measured against the way you're flying, it speeds you up (`AIR_ACC`, but never past your take-off speed, or the walk speed if that was slower), turns you (`AIR_TURN`) and slows you (`AIR_BRAKE`), so holding back stops a running jump instead of turning you round, and holding sideways for a whole jump moves you about 2.3; from a standing jump the stick gets the full `AIR_ACC`. Sections keep the step from one route part to the one after next above 3.67 (a big jump can't skip a part), keep beams longer than a running jump, and make hazards too tall or too fast to simply hop. When changing a section, also try running jumps (with the real `simStep`) from each part of its route to every later one, to make sure none can be skipped. A section can offer a second way through: Fork in the Road has a slow lift and a gold shortcut (a narrow beam through a laser, a truss and two pillars, with a SHORTCUT sign, from a part's `sign`); its `build` takes a fourth argument `alt` that routes the bot through the shortcut, and `verifyModule(id, d, mir, t0, seed, alt)` checks that way too. Each section in `MODS` is built in its own frame: it starts on the 4 × 4 pad centred at (0, 0, 8) and must end with `B.exit(H)`, its exit pad at (0, H, -8), staying inside radius 12.5 and above y = 0. Towers are versioned so everyone in a room builds the same one: `towerPlan(seed, n, easy, v)` with `v` 1 is the original 19 sections in the original order (kept exactly, for a host on an older copy of the page), and `v` 2 (`TOWER_V`) adds Gust Gaps, Ice Steps, Launch Pads and Fork in the Road (marked `v: 2` in `MODS`) and climbs steadily: each slot takes the unused section whose difficulty is nearest a target rising from 1.4 to 4 (with a little chance mixed in), and the tightness `d` rises from about 0.12 to 0.72. Towers turn every other section 180° and may mirror any, and between sections there is a porch, a truss and a landing 5.5 higher (`RISE`), more than a jump plus a body (5.37), so nothing you can stand on in one section lets you reach the next one's low parts. Every section also lists a route for the bot (`B.j`, `B.w`, `B.jon`): before each jump the bot simulates it with the real `simStep` and only jumps when it lands (in the air it asks for just the speed that brings it down over the target, `aimAir`, as a player who commits to a jump would), and it waits or hops past hazards, so a route that completes proves the section can be beaten with the real movement numbers. Each landing between sections is also checkpoint `k` (`cp` on the part, its spot in `W.cps[k]`). Towers can have checkpoints (on your own, the Checkpoints switch on the menu, saved as `spire:cpOn`, on by default; online, the host's Checkpoints option, `cp` in the round): then reaching a landing saves your place (a mint landing, a fanfare and a mint mark on the height bar), anything lethal or R puts you back on it, and dropping more than 4 below it counts as a fall and does the same. Without checkpoints, red sends you to the bottom and a fall just lands you lower, as before. Either way the first time you reach each landing the feed shows your split time, and the fastest-tower best counts both (a clean run is just as quick either way). Coins float over two spots on each section's route (the same ones for everyone in a room, picked from the tower's seed): each one you pass through is one coin, picked up in the physics step. When adding or changing a section, run the bot over it at several difficulties, mirrored and not, and at several start times, and over whole towers (`verifyModule`, `runBot`; the page exposes them as `window.__tw` in automated browsers). Online, like Chromaflage, everything travels through each player's own node at `rooms/tw-/players/`, which must always hold `n, c, x, z, h, ts`: position and animation (`y`, `a`), the round the player is in (`r`) and a finish claim (`f`, `round:milliseconds`). The host (newest host number `he`, else whoever has been in the room longest, chosen only once the room's players have loaded) publishes the round as JSON in its own `rs`: `{id, seed, ph, t0, dur, n, ez, ff, rf, fin, ne, cp, v}`, where `seed` builds the tower (with tower version `v`; a round without `v` is version 1 and one without `cp` has no checkpoints, so a host on an older page still works), `t0` is the server time it starts, `ff`/`rf` mark the first finish (from then the clock runs at double speed) and `fin` is the finish order. Other players check the round before using it (`cleanRS`: finite times within a day of now, a finish list of `[uid, ms, name]`, names cleaned), so a broken host can't freeze their page. The host takes finish claims at their word, so it isn't cheat-proof. If the host leaves, the next player carries on from the last round it saw. A tab in the background gets no animation frames, so a 1 s timer keeps its node's `ts` fresh and, for the host, keeps the round ticking. Nothing about a round is kept online after it ends. Saved only in the browser, under `spire:` keys: name, colour, hat (`spire:hat`), checkpoints on your own (`spire:cpOn`), settings, the host's round options (now with `cp`), and a profile (`spire:profile`: coins, XP, towers climbed, best times, falls, the furthest obby stage, best practice times and the hats bought with coins, `hats`), `spire:awarded` (the last online round that paid out, so rejoining it doesn't pay twice) and `spire:climbed` (set after the first truss climb; until then a tip shows at the foot of a truss). Hats (`HATS`): a cap, party hat, beanie, top hat, crown and traffic cone unlock with your level, and a halo, Viking helmet, propeller cap and wizard hat cost 100 to 500 coins (the menu's Hat row; a locked one says what it needs, or offers to buy it). Your hat travels online as `k` on your node. In a tower the sky runs on toward sunset as the camera climbs (`skyAt`); online a place pill beside the clock shows where you are (finishers in order, then everyone else by height), and the height bar has a strip in each section's colour and a gold ring on the leader. Climbers squash and stretch as they jump and land, and flying fast (a launch pad, a long fall) brings in speed lines and widens the view a little. Keys use `keybinds.js` (`keybinds:spire`). V (the `view` action) switches between the camera behind you and first person, as does scrolling all the way in or out; in first person your body moves to layer 1, which only the sun's shadow camera sees, so it's hidden but still casts its shadow, and spectating always uses the camera behind the climber you watch. The choice is saved as `spire:view`. On computers the mouse aims: clicking the game while playing captures it (Pointer Lock), so moving it turns the camera with no button held (0.0026 radians per pixel times Sensitivity, pitch kept to the same limits as before), and a crosshair replaces the cursor (a dot in first person). While aiming in third person the camera sits over your right shoulder and you turn to face where you aim as you move; Shift lock also keeps you facing it standing still. Esc, the pause menu, results, the Controls panel, the menus and spectating all let go of the mouse (only Esc and losing it some other way bring up the pause menu), and a small "Click to aim" shows while it's free during play; you can still move then. If the browser refuses the lock three times running (Chrome refuses a request within about a second of Esc), the hint goes and the old drag-to-look carries on, but every click still tries again. Settings and the pause menu have Sensitivity (`spire:sens`, shared with touch) and Invert Y (`spire:invY`, also for touch, off by default). On touch screens the page adds `touch` to `body` for a move stick, a Jump button, an eye button for first person, drag to look and pinch to zoom, with the Controls buttons hidden. Drawing: parts that never change are merged into one mesh per look and per four sections (vertex colours; the bevelled edges and side shading come from a per-face `fe` attribute that `boxGeo`/`cylGeo` add), while moving, blinking and crumbling parts and checkpoints keep their own meshes; lethal parts are unlit neon with a glow. Scenery (hills, trees, mountains, clouds, the obby's islands) is one mesh each, the sky is one shader, and dust, sparkles and confetti are two point buffers. Graphics Pretty (`spire:gfx` `high`, the default on computers) adds soft sun shadows that follow you, a second cloud layer and more particles; Fast (`low`) is the default on phones. Parties can launch it (its row in `GAMES` in `party.js`, `{ k: 'tw', n: 'Spire', d: 'spire', max: 12, nk: 'spire:name' }`), the Online panel offers room invites to it, and it's in the feedback box's game list. It was archived for a while (October 2026) and brought back with checkpoints, the new sections, coins and hats. **Spanish:** it loads `../lang.js` and its own words in `spire/es.js` (sections, worlds, hats and the made-up tower names, which es.js builds from the two word lists, so keep it in step if those lists change); canvas signs use `T()`, and there is an EN | ES switch next to Controls in Settings and the pause card. - `e63334287a3deaa3/turbo-trail/`: Turbo Trail (Back Room), a speedrun obby: 25 short levels (about 6 to 12 seconds each at gold pace) in five worlds of five, Candy Coast, Neon City, Lava Forge, Frost Peaks and Star Drift, each with its own sky, sea, palette and scenery (Three.js, Firebase Realtime Database race rooms under `rooms/sr-…`, same project and rules as Rumble Karts; Quick match uses `rooms/sr-pub-1` to `sr-pub-4`; invite links go through the home page as `#sr-`; rooms hold up to 12). Everything that isn't drawing lives between the `// ==CORE==` and `// ==/CORE==` markers in the page, with no DOM or Three.js in it, so a Node script can run it on its own: movement (`PHYS`, `simStep`), parts (upright boxes and cylinders, optionally moving by `line`, `spin` or `orbit`, blinking (`timed`), crumbling, lethal, a jump pad (`bounce`), a climbing wall (`wj`), ice, or a zone: `speed` pads, `lowg` low gravity and the `portal`), the level builder (`Course`), the levels (`WORLDS`, `LEVELS`, `buildLevel`) and the checking bot. Physics is a fixed 120 Hz step with the runner as an upright cylinder (radius 0.42, height 2), so it plays the same at any frame rate (a slow frame runs several steps; nothing moves more than 0.5 in one step, and the thinnest solid or lethal part is 0.25), and parts are found through an x/z grid of 10 × 10 cells. Running speed is 12.5 with snappy acceleration, a jump rises 3.24 and carries about 9 at full speed, with 0.12 s of coyote time and a 0.14 s jump buffer; in the air the stick speeds you up, turns you and brakes you (`airControl`) but never past your take-off speed. Speed pads push you to 27 along their arrows (the extra speed fades on the ground in about a second and stays in the air), jump pads throw you 7.8 up, and touching a striped climbing wall in the air lets you jump again off it (up 16.5, 8 away from the wall, keeping your speed along it; you also slide down it slowly). Levels are written with the `Course` cursor (`start`, `run`, `gap`, `stones`, `blocks`, `pad`, `bounce`, `bars`, `stairs`, `movers`, `pistons`, `spinner`, `lasers`, `wallrun`, `chimney`, `crumble`, `blinks`, `slalom`, `lowg`, `orbit`, `drop`, `turn`, `portal`); each piece also adds the checking bot's route. The bot plays with the real `simStep`: before each jump it simulates the jump and only takes it if it lands, it hops or waits for hazards, and it pushes off climbing walls; when changing a level, run the bot over it at several start times (moving parts depend on the clock) and at the top upgrade speed (`runBot(buildLevel(i), t0, 90, run)`). The medal times in `MEDALS` ([gold, silver, bronze] per level) come from the bot: gold is its median time over several start times plus 4% and 0.25 s, rounded up to a quarter second, silver is 1.3 × gold and bronze 1.75 × gold, so they need re-working out if a level changes. A level's clock starts with your first move and a fall, a lethal part or R puts you back at the level's start with the clock reset; in a Full run (all 25 on one clock, starting with your first move on 1-1) the clock keeps running through falls and T starts the run over. After each portal the split (your full-run time there against your best run's, or the level time against your best) shows green when ahead and red when behind. Stars: 1, 2 or 3 for a bronze, silver or gold best; they unlock speed upgrades (`SPEEDS`: +4%, +8%, +12% at 12, 30 and 50 stars, chosen in the Garage and used online too) and trails (`TRAILS`, at 3 to 75 stars; a camera-facing ribbon of the last 0.45 s, one draw call). Saved only in the browser under `turbotrail:` keys: `name` (a plain string, which party.js puts back after a party launch), `color`, settings (`sens`, `invY`, `follow`, `ghost`, `vol`, `mus`, `gfx`, `zoom`, `slock`, `hostC`, `room`), `prog` (`{reached, best: [25 times], run: {t, sp: [25 splits]}, speed, trail, clears, falls, runs}`), `ghost:` (your best run on that level, 20 samples a second as comma-separated whole tenths of x, y, z and hundredths of the facing, replayed as a see-through runner when Best ghost is on) and `awarded` (the last race win counted). Online, like Spire, everything travels through each runner's own node `rooms/sr-/players/`, which must always hold `n, c, x, z, h, ts`: also `y`, `a` (animation, 5 while respawning), `l` (which level of the course you're on), `r` (the race the position belongs to), `tr` (trail), `j` (join time) and `f` (a finish claim, `race:milliseconds`). The host (newest host number `he`, else whoever has been in the room longest, chosen once the room has loaded) publishes the race as JSON in its own `rs`: `{id, ph: 'race' | 'inter', t0, cs, nm, fin, ff, ne}`, where `cs` is the course (a random world's five levels, five from all over, or all 25: the host's Course option in the pause menu, saved as `turbotrail:hostC`), `t0` the server time it starts (a 5 s countdown), `fin` the finish order `[uid, ms, name]` and `ff` the first finish; the race ends when everyone live has finished, 30 s after the first finish, or after 45 s a level plus 20 s, then results show for 9 s and the next race starts. Guests clean the host's race before using it (`cleanRS`), so a broken host can't freeze them. The race clock is the simulation clock, so every runner sees the moving parts in the same places; other runners are see-through ghosts (with their trails) drawn from a short history of their updates with `../netsmooth.js`, only while they're on the same level as you, and a list on the right shows everyone's progress. The host takes finish claims at their word, so it isn't cheat-proof. A background tab keeps its node fresh (and, for the host, the race moving) with a 1 s timer. Camera: behind you, pulled in so it never ends up inside a wall, easing round to the way you're running while you hold forward (not while strafing, and not for 0.7 s after you turn it yourself; Settings → Camera: Free turns that off), and a little wider at high speed. On computers clicking the game captures the mouse (Pointer Lock) to look around; Esc frees it. Keys are rebindable with `keybinds.js` (`keybinds:turbo-trail`). On touch screens the page adds `touch` to `body`: a run stick, Jump, a restart button, and drag anywhere else to look; Fast graphics by default. Drawing: parts that never change are merged into one mesh per look (bevelled edges from a per-face `fe` attribute, as in Spire), moving, blinking and crumbling parts keep their own meshes, scenery is one mesh per level, the sky one shader and particles one point buffer, so a level is about 20 to 30 draw calls; Pretty graphics adds sun shadows. Leaderboards hooks: `BackRoomStats.min('obby', seconds)` for a finished full run (`obby` is already in stats.js's `LOWER` list; stats are kept per game folder, so it doesn't mix with Spire's), `max('stars', total)`, `add('levels', 1)` at every portal and `add('wins', 1)` for winning a race against at least one other runner. Ads follow the `AD_SLOT` pattern (empty). A test hook (`window.__sr`, with `advance(seconds)`, `autopilot(on)` and `buildLevel`/`runBot`) exists only when `navigator.webdriver` is set. **Spanish:** it loads `../lang.js` and its own words in `turbo-trail/es.js` (level names stay English; signs drawn on canvases use `T()` and follow the language when the level is built), with an EN | ES switch next to Controls in the menu and pause card. - `e63334287a3deaa3/escapade/`: Escapade (Back Room), a 3D escape-room obby (Three.js, Firebase Realtime Database rooms under `rooms/er-…`, same project and rules as Rumble Karts; Quick match uses `rooms/er-pub-1` to `er-pub-4`; invite links go through the home page as `#er-`; rooms hold up to 12). **Worlds:** six worlds of eight levels (48), each level a themed set of rooms with one way out, harder world by world. World 1, Breakout (Detention, Lab Rats, Hot Kitchen, Toy Box, Down the Drain, The Vault, Orbit Station, The Warden), is built into `index.html`, unchanged. World 2, Lost and Found (Overdue (a library), Clockwork (a clock tower), Cold Feet (an ice cave), Lost Temple, Mirror Manor (a haunted house), Stage Fright (a theatre), Gale Point (a lighthouse in a storm) and After Hours (a museum, the world's finale)), is `escapade/worlds/w2.js`; its first five were levels 9–13 before worlds came, with the same ids. World 3, Deep Down (Cave-In (an old mine), Deep End (a flooded cave), Off the Rails (an underground railway), High Water (a pump station), Fish Tank (an aquarium), Crystal Clear (a crystal cavern), Hull Breach (a sunken ship) and Hot Core (a volcano, the world's finale)), is `escapade/worlds/w3.js`; it added water you swim in (jump strokes up; an Air bar while your head is under), minecarts on rails (`rail`), water and lava that rise (`rise`, started by a flag or a trigger zone) and dark rooms you need the lantern for (`B.dark`, item `lamp`). World 4, Full Power (Assembly Line (a toy factory), Sorting Day (a recycling plant), Spin Cycle (a power station), Growing Pains (a greenhouse), Hot Swap (a data centre), Night Shift (an observatory), Spare Parts (a robot lab) and Meltdown (a power plant, the finale)), is `escapade/worlds/w4.js`; it added belts and fans a lever turns round (`rev`), pressure plates you stand on (`B.hold`), presses and piston walls that crush (`B.crusher`, `B.press`) and red, green and yellow keycards with their doors (`B.cardDoor`). World 5, Sky High (Hot Air (a balloon festival), Big Top (a flying circus), Thunderclap (a skyscraper in a storm), Sky Deck (a revolving restaurant), Zeppelin (an airship), Cloud Keep (a castle in the clouds), Orbiter (a satellite) and Eye of the Storm (a weather station in a hurricane, the finale)), is `escapade/worlds/w5.js`; it added updrafts (`B.lift`), cannons you fire yourself from (`B.cannon`, a `{w5: 'cannon'}` button), lightning on a timer with rods that power gates (`B.bolt`), groups of parts that turn a step at a press (`B.turning`, `B.turnBtn`, `B.align`) and the `clouds` scenery. World 6, The Last Door (One Way Home (a labyrinth with one-way flaps), Sun and Sand (a pyramid), Siege Works (a fortress), Dragon's Wake (a dragon's keep), Borrowed Time (a vault of clocks), Upside Dream (a dream), Long Climb (a climb over a molten sea) and The Last Door (the Keeper, a three-phase boss, and the end of the game)), is `escapade/worlds/w6.js`; it added one-way flaps (`oneway: [nx, nz]`, `B.oneway`), rings of fire you jump (shape `ring`, move `pulse`, `B.ring`) and the shadow (`B.shadow` zones: a chaser that walks your own path a few seconds behind you); escaping its last level shows "You beat Escapade!". Each of Worlds 3–6 keeps its shared code in its own marked blocks in `index.html` (`// ---- World core additions ----` inside the CORE, `// ---- World drawing additions ----` outside it) with one-line hooks ending `// W hook`; each does nothing unless a level uses it, and `worlds/README.md` section 13 lists every helper. Worlds 3–6 are `needs: 3` (`CORE_VER` 3). Each world after the first is its own file, `worlds/w.js`, loaded only when it's needed (picked in the menus, the level an online room is playing, or the next world when you reach a world's last level), so the page stays small; a world file only describes levels (`Escapade.world({n, needs, levels})`), and every shared helper, puzzle part and the bot live in `index.html`. **`escapade/worlds/README.md` is the guide for building a world**: the API, every helper and puzzle with its parameters, seeds, checkpoints, stars, the bot route, the tests a level must pass, a performance budget, a difficulty guide and the mechanics already used. The `WORLDS` list in `index.html` (one line per world: name, colour, blurb and its eight level ids) is what the menus show before a file loads and what progress counts by. `CORE_VER` goes up when the page gains something world files can use; a file says which one it needs, and a page too old for it (or one that can't load it) shows an "Update needed, reload" notice instead of breaking. Everything that isn't drawing lives between the `// ==CORE==` and `// ==/CORE==` markers: movement (`PHYS`, `simStep`, Spire's numbers: jump 3.37, 3.67 with the ledge pop, run 7.5, fixed 120 Hz step, so the frame rate never changes the physics), parts (upright boxes and cylinders, filed in a 6 × 6 xz grid for collision; moving by `line`, `spin` or `orbit`; timed, crumbling, lethal, bouncy, conveyors, ladders, low-gravity zones; and for levels 9–13: `ice` (slippery: you speed up and stop slowly, `PHYS.ICE_ACC`/`ICE_DEC`), the move types `swing` (a pendulum: platforms and blades that stay level, hanging `len` below a pivot) and `roll` (one way at a steady speed, then round again: the temple's boulder), ladders (trusses) that move and carry you while you hang on (stick off = hang, stick into it = climb), `tp` portals (`[x, y, z, yaw]`: where they send you; put the arrival point a little above the floor), zones `cold` (you freeze after `PHYS.COLD` seconds in it, shown as a Warmth bar) and `warm` (a fire thaws you), and `slide` crates (one shove and they slide until something stops them); and for World 2's last three: zones `wind` (`wind: [vx, vz]`, blows you along on the ground and in the air, in gusts when `timed`; white streaks show it, fainter just before a gust; the bot leans into it), the lever button `{toggle}` (flips a flag on and off, for scenery that swaps with `onIf`/`offIf`) and `B.all(flags, set)` (a flag that comes on once all of its flags are: the museum's vault), plus level options `sea` (a molten sea to the horizon instead of the lawn) and `msgs`/`unlock` (a level's own feed messages and Unlocked! banners)), the puzzle parts and `logicStep`/`useBtn`/`tryCode`, the level library (`LEVELS`, each with a `par` target time and a `build` that also writes the checking bot's route) and the bot; it has no DOM or Three.js in it, so a Node test can run it on its own. **Puzzles are flags** in the level's state `W.st.f`: a part with `door: 'flag'` is solid until the flag is on (a number means "on until that time": timed gates); `onIf`/`offIf` make a part exist only while a flag is on/off (the space bridge, the Warden's arms); `lock: 'item'` opens a door when you come near carrying the item; `item` parts are pickups (`key`, `card`, `fuse`, `gem`); `btn` parts are used with E / the USE button: `{set}` (a button), `{timed, dur}` (a valve), `{seq, sym}` (recipe buttons, pressed in the order `W.seqs[g].order`), `{pad}` (a keypad; the code is `W.codes[k]`, four digits from the level's seed), `{need, then}` (a fuse box), `{dial, key, n}` (turns one hand of the clock: `W.dials[g]` holds the target time, from the seed; all of a group's dials on target sets its flag), `{mirror}` (turns a mirror a quarter; `beamTrace` follows the moonbeam in `W.beams[g]` across the floor, and the beam reaching its target sets the flag); `plate` parts latch a pushed crate (`push`, kept inside `lim`, pushed along one axis at a time) and set their flag; `step` parts (`{seq, sym}`, the temple's stones) count when you land on them, in the order `W.seqs[g].order` (the mural shows it). The library's code is `W.codes.lib`, its digits shown on four coloured books in the order `W.books.lib`; the manor's right mirror is the colour `W.rose` (from the seed, like every other clue). Walls are 10 tall (22 in the low-gravity bay) so nothing standable gets you over them. Each level keeps the puzzle in its own copy for every player: there are no shared doors, so nobody can open or block anything for anyone else. **Stars**, saved in this browser under `escapade:prof` (`{best: {levelId: seconds}, st: {levelId: bits}, esc, deaths}`; bits 1 escaped, 2 beat `par`, 4 found the gem; the gem counts once found in any escaped run), by level id as always, so saves from before worlds came load as they were (8 escaped shows World 1 done and World 2 open; 13 shows World 2's first five done). The menus: Play carries on from the first level you haven't escaped; Worlds shows a card per world (name, stars of 24, how many escaped, locked or coming soon), then that world's eight levels. A level opens when you escape the one before it in its world; a world opens when you escape the last level of the one before it (or any of its own levels, say online). The menu counts escapes of 48 and stars of 144. Death (touching anything red and glowing, or falling) respawns you at your last checkpoint after 0.6 s; what you found and opened stays, crates not on their plate go home, crumbled tiles come back and timed gates shut (`softReset`). On your own the clock stops while paused or while the keypad is open. **Online**: each player writes only their own node `rooms/er-/players/`: `n, c, x, z, h, ts` as the shared rules require, plus `y`, `a` (animation), `j` (join time), `rr` (the round you're playing), `f` (your finish, `round:ms:server time`) and, from the room's leader only, `lr`/`ll`/`lt` (round number, level, start time). The leader is the live player who joined first (`Net.leader`); everyone else follows the leader's round, loading that level with a seed made from the round (so codes and recipes match for everyone) and running moving parts from `lt`, so all players see the same moving platforms. Late arrivals' own clocks start when they arrive. When everyone in the room is out (6 s later), or two minutes after the first escape, the leader starts the next level; the leader can also pick a level from the pause menu. If the leader leaves, the next one carries on with the same round. Other players are drawn with `../netsmooth.js` and only while they're in your round. Every value read from another node is checked (`onNode`). Each node also has `v`, its page's `CORE_VER`. The leader can pick any level in the worlds and levels it has opened itself (pause menu, Pick the room's level); everyone else loads that level's world file when they see the round (the round starts 4.5 s later, and a late loader's clock starts when it arrives), and a page that doesn't know the level shows the update notice. Pages from before worlds came (no `v`) only know levels 1–8 and simply don't follow a later level: the room list says they need to reload and the leader's feed names them. Keys are rebindable through `keybinds.js` (`keybinds:escapade`, actions `forward`, `back`, `left`, `right`, `jump`, `use`, `shiftLock`, `view`, `zoomIn`, `zoomOut`, `reset`). Touch: stick, JUMP, USE (green when something can be used), drag to look, pinch to zoom; shown only on touch screens. Other saved settings: `escapade:` `name`, `color`, `room`, `sens`, `invY`, `vol`, `mus`, `gfx`, `view`, `zoom`, `slock`. Leaderboards hooks: `BackRoomStats.add('escapes', 1)`, `max('cleared', n)` (levels escaped, up to 48), `max('stars', n)` (up to 144), `min('total', seconds)` (World 1's best total: the sum of its eight best times once they all have one, as before worlds came, so totals already on the board still compare; the menu calls it "World 1 total") and `min('total-w', seconds)` for each later world (`total-w2` … `total-w6` are in `stats.js`'s `LOWER`; the board has a row for each world). Ads follow the `AD_SLOT` pattern (empty). A test hook (`window.__er`, with `advance`, `frames`, `autopilot`, `depth`, `ensureWorld`) exists only when `navigator.webdriver` is set. **When changing a level**, keep the route in its `build` working and re-run the bot on it at several start times, and check that every puzzle door is still needed: with one door kept shut and all the others open, running, jumping and running jumps from everywhere reachable must not reach the exit (the checks used for this branch ran exactly that on all eight levels; levels 9–13 were checked the same way, with the search keeping the whole player state so rides on moving ladders count, and with each portal taken away in turn: the manor's right mirror and its last mirror are needed; World 2's last three too, with levers as part of the search: the theatre can't be crossed with its levers left either way, and its stage door, the lighthouse's beacon and the museum's vault and exit doors are all needed). Worlds 3–6 were checked the same way: the bot from the spawn and from every checkpoint at several seeds and start times, the search with each gate shut in turn (extended to swim, ride carts, carry keys and turn the turning rooms), random runners for clipping, draw calls, phones and an online room; the merged page still plays Worlds 1 and 2 exactly as before (same parts, codes and bot runs). The checking bot has route steps for the new things: `ladder` (a plan saying wait, grab, hang or climb), `dial`, `tp`, `kick` (a sliding crate) and `steps` (stepping stones, by way of a hub platform). **Spanish:** it loads `../lang.js` and its own words for the page and all six worlds in `escapade/es.js` (a new level's signs and messages need their Spanish added there, or they show in English); level and world names and the EXIT sign stay English. Every canvas made by `cvs()` passes its text through `TX()` while the language is Spanish, so the world files need no changes, and compass dials show N E S O. The puzzles are codes, colours, clocks and pictures, not English words, so none is English-only. EN | ES switch next to Controls. @@ -105,7 +105,7 @@ Personal site hosted with GitHub Pages at **https://ascoding11.github.io**, the - **Chests** (called draws inside the code: pack ids `draw-1/5/10`, kind `draws`, `draw()`). A chest costs 7 emeralds (119 mangos; 5 chests 35 emeralds, 10 chests 70, no discount), is bought with emeralds only, and gives one random skin. Odds are weights out of 10,000, shown in the shop next to the chest: common 6,000 (60%), uncommon 2,000 (20%), rare 1,250 (12.5%), epic 500 (5%), legendary 250 (2.5%). They are picked with an unbiased whole-number roll: `crypto.getRandomValues` in play, `seeded(n)` in tests. A duplicate gives back 48 mangos (40% of a chest, rounded). - **Packs.** `PACKS` holds what is bought with emeralds, with prices in whole mangos: chests (1, 5 and 10), themed skin packs, accessory packs and game item packs. Every pack of items costs the sum of its items' prices. `buy(id)` (a pack id, or `item:` for one item) checks the wallet, takes the mangos, fills the locker and refunds duplicates; something already fully owned is refused, and an emerald pack id is refused with reason `money`. - **Captains.** Captains (`captains.js`, which asks miles.js's `OWNERS`; Vice Captains are not included) have no limit while the cosmetics are on: the shop's wallet and the Shop chip show "∞", `spend()` never charges them (a log line says it was free), every skin, accessory and game item counts as owned (`load()` in `cosmetics.js` lists everything, and `save()` writes back only what they really own, so nothing extra is mirrored into their account or kept after they sign out), they are never paid rewards, and their gifts are free. The shop page now loads `captains.js` without `data-switches` so it can tell who is signed in. - - **Weekly titles.** Every week (Monday to Sunday, the boards' own week), whoever is #1 on a game's main board gets 10 mangos for that game, for each week they hold it, and 10 more for each other game they top; ties for #1 all get it. The main board is the first board `leaderboard.js` lists for the game after Hours, all time: Rumble Karts, Shell Crackers, Backrooms 1v1–4v4, Driftfall, Lokop, Slipstream, Boostball, Chromaflage, Turbo Trail, Odd One Out, Tumble Trials, Deepword and Puffer Party: Elo; Blockstorm and Sky Duel: Most kills in a match; Coil: Longest snake; Trivium: Best Daily score; Showdown: Biggest pot (practice); Spire: Fastest tower; Escapade: Stars; Updraft: Fastest to the Crown; Asteroid Run: Longest Endless run; Rampline: Medals; Tidewick, Gridpop, Melon Merge, Patchwork Tower and Flickerwood: Best score; 2048 and Stackfall: Best score (Classic); Lanternhold: Most waves held; Daily Puzzles: Best daily streak; Hunch, Fourcast, Quartets, Nearword, Warmer, Hotspot, Outline, Unfurl, Overland and Poopdle: Daily wins; Crosslet: Clean daily solves; Sleight: Daily clues solved; Ninefold: Daily puzzles solved; Deadline Day, Journeyman, Scout Report and Teamsheet: Most guesses to spare; Crossbar: Most squares filled; Back Four: Most mistakes to spare; Stat Duel: Best daily run; Top Bins: Most entries found. The winner's own page claims it at its first scan after the week ends (`wallet.js` `scan()`, at most every 10 minutes per browser on hub pages and every time the shop opens), judged from the boards as they stand at that moment, since nothing records how they stood on Sunday night. A captain at the top is not paid and nobody else is paid for that board: `leaderboard.js` shows captains like anyone, so they keep the top spot. The claimed week is kept as `tw`. + - **Weekly titles.** Every week (Monday to Sunday, the boards' own week), whoever is #1 on a game's main board gets 10 mangos for that game, for each week they hold it, and 10 more for each other game they top; ties for #1 all get it. The main board is the first board `leaderboard.js` lists for the game after Hours, all time: Rumble Karts, Shell Crackers, Backrooms 1v1–4v4, Driftfall, Lokop, Slipstream, Boostball, Chromaflage, Turbo Trail, Odd One Out, Tumble Trials, Deepword, Puffer Party and Sky Duel: Elo; Blockstorm: Most kills in a match; Coil: Longest snake; Trivium: Best Daily score; Showdown: Biggest pot (practice); Spire: Fastest tower; Escapade: Stars; Updraft: Fastest to the Crown; Asteroid Run: Longest Endless run; Rampline: Medals; Tidewick, Gridpop, Melon Merge, Patchwork Tower and Flickerwood: Best score; 2048 and Stackfall: Best score (Classic); Lanternhold: Most waves held; Daily Puzzles: Best daily streak; Hunch, Fourcast, Quartets, Nearword, Warmer, Hotspot, Outline, Unfurl, Overland and Poopdle: Daily wins; Crosslet: Clean daily solves; Sleight: Daily clues solved; Ninefold: Daily puzzles solved; Deadline Day, Journeyman, Scout Report and Teamsheet: Most guesses to spare; Crossbar: Most squares filled; Back Four: Most mistakes to spare; Stat Duel: Best daily run; Top Bins: Most entries found. The winner's own page claims it at its first scan after the week ends (`wallet.js` `scan()`, at most every 10 minutes per browser on hub pages and every time the shop opens), judged from the boards as they stand at that moment, since nothing records how they stood on Sunday night. A captain at the top is not paid and nobody else is paid for that board: `leaderboard.js` shows captains like anyone, so they keep the top spot. The claimed week is kept as `tw`. - **Weekly Aisle reward.** The Aisle that wins last week's contest in `aisles.js` (most miles flown; a tie: every tied Aisle) gets 100 mangos split evenly: each member gets floor(100 / members) (16 each for 6), and the leftover mangos are not paid. Each member's own page claims their share on the Back Room page (it needs `aisles.js` and the boards read there), once per week (`aw`), using the Aisle's members at that moment. - **Gifts.** Every skin, accessory, game item, pack and chest in the shop has a Gift button next to Buy: the same price (free for captains), sent to someone picked from the people online (`social.js`'s room), the sender's Aisle and party, each of whom must be signed in with Google; an optional note of up to 60 characters goes through `/namefilter.js`. Emeralds and mangos can't be gifted, and a single skin or accessory their account is known to own is refused (game items aren't mirrored, so those and anything in a pack already owned become the duplicate refund for the recipient). Players can only write their own node, so the gift is written into the sender's own `w.gs` (at most 3 unopened at a time); the recipient's page finds it in its next scan, puts it in their locker (a chest opens there), shows "Morgan sent you a gift: Golden Egg" and records the sender's newest claimed gift time in its own `w.gc`, which is how the sender's page knows to forget it. Both sides get a log line. The sender must be signed in with Google so the gift can be published. - **All client-side.** Captains' passes, titles, Aisle rewards and gifts are all worked out in the player's own browser, so with real money on, a player could fake a title, an Aisle win or a gift from the browser console. Before real money is switched on, grants and gifts must move to a server ledger (Cloud Functions writing a store players can't write). Every grant already goes through one function, `grant(kind, detail)` in `wallet.js`, marked as the piece to move server-side. @@ -121,7 +121,7 @@ Personal site hosted with GitHub Pages at **https://ascoding11.github.io**, the - `e63334287a3deaa3/lang.js`: English / Español for the whole Back Room (see the comment at the top of the file for the full how-to). Loaded with one plain ``) and calls `BackRoomElo.report({ id, won, opp: [{ u: uid, s }, { bot: 1, s }] })` once where its online match or round ends (search each game for `BackRoomElo`): `opp` is everyone you played against, not teammates, and `s` is your result against that one opponent (1 beat them or your team won, 0 lost, 0.5 drew), so team games give every opponent the same `s`, races and free-for-alls go by finishing place, Driftfall counts everyone already out as beaten and everyone still alive as a loss, Tumble Trials rates once per show (when you go out or the final ends), and in Chromaflage a seeker beats each hider that was found while a hider beats the seekers by staying hidden. The change is the usual Elo one (K 36 for the first 10 matches, then 24), averaged over the opponents and multiplied by the number of real opponents (×1 for one, 25% more for each extra, at most ×3); bots count as rated 1000, and a match with no real opponent isn't rated, so practice and bot-only rooms never move a rating. Everyone starts at 1000 and stays in 100–3000. `id` stops a match being rated twice (results screens can be drawn more than once). Storage: this browser's `elo:` (`{ r, g, wn, pk, uid }`) and the Realtime Database at `rooms/elo-/players/` (`n, c, x, z, h, ts` as the shared rules need, plus `r, g, wn, pk`), written by the player's own browser; on load the account's saved rating wins, and opponents' ratings are read from their nodes when a match is reported. So, like every Back Room stat, it is self-reported and not cheat-proof. It never signs in or makes a Firebase app itself (it uses the game's), and every call swallows its own errors, so it can't stop a game. After a rated match a small pill at the top shows the new rating and the change. stats.js reads `elo:` into the game's `elo` stat (the list of folders is next to `READ`), and leaderboard.js has an Elo board first for each of these games (for Slipstream, after its lap and record boards); as with Shell Crackers, the board keeps the best value it has seen, so it shows a player's highest rating. To rate another game: add the script tag and one `report` call, add its folder to the list in stats.js, and add the Elo row to its entry in leaderboard.js. +- `e63334287a3deaa3/elo.js`: ranked ratings (Elo), one per game, for the online games that end with a winner: Boostball, Rumble Karts, Backrooms 1v1–4v4, Driftfall, Slipstream, Turbo Trail, Tumble Trials, Chromaflage, Odd One Out, Puffer Party, Deepword's Brawl, Lokop and Sky Duel. Shell Crackers keeps its own older rating (`shellcr-rank`, `rooms/sc-ratings`) and doesn't load this file; the maths here is the same as its. Each game loads it next to stats.js (``) and calls `BackRoomElo.report({ id, won, opp: [{ u: uid, s }, { bot: 1, s }] })` once where its online match or round ends (search each game for `BackRoomElo`): `opp` is everyone you played against, not teammates, and `s` is your result against that one opponent (1 beat them or your team won, 0 lost, 0.5 drew), so team games give every opponent the same `s`, races and free-for-alls go by finishing place, Driftfall counts everyone already out as beaten and everyone still alive as a loss, Tumble Trials rates once per show (when you go out or the final ends), and in Chromaflage a seeker beats each hider that was found while a hider beats the seekers by staying hidden. The change is the usual Elo one (K 36 for the first 10 matches, then 24), averaged over the opponents and multiplied by the number of real opponents (×1 for one, 25% more for each extra, at most ×3); bots count as rated 1000, and a match with no real opponent isn't rated, so practice and bot-only rooms never move a rating. Everyone starts at 1000 and stays in 100–3000. `id` stops a match being rated twice (results screens can be drawn more than once). Storage: this browser's `elo:` (`{ r, g, wn, pk, uid }`) and the Realtime Database at `rooms/elo-/players/` (`n, c, x, z, h, ts` as the shared rules need, plus `r, g, wn, pk`), written by the player's own browser; on load the account's saved rating wins, and opponents' ratings are read from their nodes when a match is reported. So, like every Back Room stat, it is self-reported and not cheat-proof. It never signs in or makes a Firebase app itself (it uses the game's), and every call swallows its own errors, so it can't stop a game. After a rated match a small pill at the top shows the new rating and the change. stats.js reads `elo:` into the game's `elo` stat (the list of folders is next to `READ`), and leaderboard.js has an Elo board first for each of these games (for Slipstream, after its lap and record boards); as with Shell Crackers, the board keeps the best value it has seen, so it shows a player's highest rating. To rate another game: add the script tag and one `report` call, add its folder to the list in stats.js, and add the Elo row to its entry in leaderboard.js. - `e63334287a3deaa3/netsmooth.js`: smooth movement for other players in the online games. Updates over school Wi-Fi and Firebase arrive late and in bursts, so a game that moves someone to their newest update makes them lurch and stall, and one that shows them a fixed time in the past freezes them whenever an update is later than that. Each remote player gets a `NetSmooth.lag()`, which measures how late their updates really arrive and shows them just far enough in the past that the next one is almost always already here (about a tenth of a second on good Wi-Fi, more on bad, never more than 0.45 s), easing that delay so the timeline never jumps; `NetSmooth.sample()` draws them between the two updates around that moment and carries them on for up to 0.3 s if an update is late. Used by Shell Crackers, Backrooms 1v1–4v4, Hail Mary, Coil, Quarry, Chromaflage, Odd One Out, Spire, Turbo Trail, Escapade, Updraft, Driftfall, Blockstorm, Lanternhold (teammates' pointers) and Sky Duel. Kartwheel, Slipstream, Boostball, Rumble Karts and Tumble Trials keep their own approach: cars, karts and racers are projected forward to the present from their speed, which matters more there than perfectly even motion. Settings were tuned with a simulation of good, school and bad Wi-Fi: compared with chasing the newest update, other players stall about a fifth as often and almost never lurch, for roughly a tenth of a second more delay. - `e63334287a3deaa3/autores.js`: automatic resolution for the 3D games, so they stay smooth on school laptops. Every three.js game except Quarry (which has its own version) loads it right after `three.min.js`. It watches the frame rate, and when frames drop below about 45 a second it makes every three.js renderer on the page draw at a lower resolution, a tenth at a time, down to half; when frames stay smooth it steps back up (more slowly towards a resolution that was too slow before, so it doesn't keep flipping). It multiplies whatever `setPixelRatio` the game asks for, so a game's own graphics setting still counts. The scale each game settles on is remembered in the browser (`localStorage` key `autores:`), so the next visit starts there. No game code calls it; it wraps `THREE.WebGLRenderer`. `AutoRes.scale` shows the current scale and `AutoRes.off()` turns it off for a visit. - `e63334287a3deaa3/account-nudge.js`: the sign-in nudge and account save (Back Room). Loaded on the Back Room page and the phone page (one ` + @@ -377,6 +380,7 @@

Paused

Match over

+
@@ -441,7 +445,11 @@

Match over

// ---------- tuning ---------- const SPD_MIN=62,SPD_MAX=132,BOOST_ADD=75,STALL=46,STALL_OUT=64,TURN=1.2,PITCH_MAX=1.3; const CEIL=900; // the air thins out above this and the engine fades -const BULLET_V=540,BULLET_LIFE=1.25,BULLET_DMG=6,GUN_RATE=.085,HIT_R=9; +// The planes are drawn PLANE_SIZE times the size they're built at (1.15, then 12% bigger in November 2026), and the +// bullet hit sphere grew with them (9 m to 10.08 m), so what you see is what you hit. The shooter's own browser decides +// its bullets' hits, so a page from before this change in the same room still works; its hits use the old 9 m. +const PLANE_SIZE=1.15*1.12; +const BULLET_V=540,BULLET_LIFE=1.25,BULLET_DMG=6,GUN_RATE=.085,HIT_R=9*1.12; const HEAT_UP=.024,HEAT_COOL=.3; // per shot / per second const LOCK_T=1.3,LOCK_RANGE=950,LOCK_CONE=.25,MSL_DMG=55,MSL_LIFE=6.5,MSL_TURN=1.9,MSL_MAX=4,FLARE_MAX=4,FLARE_R=520; const RESPAWN=3.2,SHIELD=2.5,PICK_R=18,PICK_RESPAWN=20000; @@ -581,8 +589,11 @@

Match over

const scene=new THREE.Scene(); const camera=new THREE.PerspectiveCamera(64,1,1.5,14000); camera.position.set(0,500,900); -let VW=1,VH=1; -function applyGfx(){renderer.setPixelRatio(Math.min(window.devicePixelRatio||1,gfx==='high'?2:touchUI?1.25:1))} +let VW=1,VH=1,waterMesh=null; +// The water: Pretty has a sun glint (per-pixel Phong); Fast lights it per vertex, the same colour without the glint. +const WATER_MAT=[new THREE.MeshLambertMaterial({color:0x2b7bb5,transparent:true,opacity:.84}),new THREE.MeshPhongMaterial({color:0x2b7bb5,transparent:true,opacity:.84,shininess:90,specular:0x9fc8e8})]; +// Pretty draws at up to 1.5 pixels per CSS pixel (2 was 78% more pixels for little to see), Fast at 1 (1.25 on phones). +function applyGfx(){renderer.setPixelRatio(Math.min(window.devicePixelRatio||1,gfx==='high'?1.5:touchUI?1.25:1));if(waterMesh)waterMesh.material=WATER_MAT[gfx==='high'?1:0]} function resize(){VW=window.innerWidth;VH=window.innerHeight;renderer.setSize(VW,VH,false);camera.aspect=VW/VH;camera.updateProjectionMatrix()} applyGfx();resize();addEventListener('resize',resize); if(window.visualViewport)visualViewport.addEventListener('resize',resize); @@ -599,9 +610,11 @@

Match over

uniforms:{top:{value:new THREE.Color()},hor:{value:new THREE.Color()},sunDir:{value:new V3()},sunCol:{value:new THREE.Color()}}, vertexShader:'varying vec3 vD;void main(){vD=position;gl_Position=projectionMatrix*modelViewMatrix*vec4(position,1.);}', fragmentShader:'uniform vec3 top,hor,sunDir,sunCol;varying vec3 vD;void main(){vec3 d=normalize(vD);float t=pow(max(d.y,0.),.5);vec3 c=mix(hor,top,t);float s=max(dot(d,sunDir),0.);c+=sunCol*(pow(s,420.)*1.6+pow(s,14.)*.28);if(d.y<0.)c=mix(hor,hor*.86,min(-d.y*4.,1.));gl_FragColor=vec4(c,1.);}', - side:THREE.BackSide,depthWrite:false,depthTest:false,fog:false + side:THREE.BackSide,depthWrite:false,fog:false }); -const skyDome=new THREE.Mesh(new THREE.SphereGeometry(9000,24,12),skyMat);skyDome.renderOrder=-10;skyDome.frustumCulled=false;scene.add(skyDome); +// Drawn after the land, clouds and planes (renderOrder 1, still before anything see-through), with the depth test on, so +// the sky shader only runs on the pixels nothing covers. Everything solid is closer than 9 km, so the picture is the same. +const skyDome=new THREE.Mesh(new THREE.SphereGeometry(9000,24,12),skyMat);skyDome.renderOrder=1;skyDome.frustumCulled=false;scene.add(skyDome); let skyIdx=-1; function setSky(i){ i=clamp(i|0,0,SKIES.length-1);if(i===skyIdx)return;skyIdx=i;const s=SKIES[i]; @@ -641,12 +654,13 @@

Match over

const g=new THREE.BufferGeometry();g.setAttribute('position',new THREE.BufferAttribute(pos,3));g.setAttribute('normal',new THREE.BufferAttribute(nor,3));g.setAttribute('color',new THREE.BufferAttribute(col,3)); const m=new THREE.Mesh(g,new THREE.MeshLambertMaterial({vertexColors:true}));m.frustumCulled=false;scene.add(m); // water, and a skirt of haze-coloured ground far out so the horizon never shows a hole - const w=new THREE.Mesh(new THREE.PlaneGeometry(30000,30000),new THREE.MeshPhongMaterial({color:0x2b7bb5,transparent:true,opacity:.84,shininess:90,specular:0x9fc8e8})); - w.rotation.x=-Math.PI/2;w.position.y=0;scene.add(w); + const w=new THREE.Mesh(new THREE.PlaneGeometry(30000,30000),WATER_MAT[gfx==='high'?1:0]); + w.rotation.x=-Math.PI/2;w.position.y=0;scene.add(w);waterMesh=w; })(); // ---------- trees (one instanced mesh) and clouds (one merged mesh you can fly through) ---------- const cloudBlobs=[]; // [x, y, z, radius] for the whiteout when the camera is inside one +let CLOUD_Y0=1e9,CLOUD_Y1=-1e9; // the lowest and highest any cloud reaches (function buildScenery(){ const rng=mulberry(4242); const nT=gfx==='high'?1500:600,cone=new THREE.ConeGeometry(7,22,5);cone.translate(0,11,0); @@ -669,7 +683,7 @@

Match over

for(let b=0;bMatch over transparent:true,depthWrite:false,blending:THREE.CustomBlending,blendSrc:THREE.OneFactor,blendDst:THREE.OneMinusSrcAlphaFactor,blendSrcAlpha:THREE.OneFactor,blendDstAlpha:THREE.OneMinusSrcAlphaFactor }); const pts=new THREE.Points(g,mat);pts.frustumCulled=false;pts.renderOrder=5;scene.add(pts); - let next=0; + let next=0,colDirty=true; // colours only change when a puff is added, so they are only re-sent then // add: 0 for smoke (covers what is behind), 1 for fire and sparks (adds light) function puff(x,y,z,vx,vy,vz,lf,sz0,sz1,r,gc,b,a,add,gv){ const i=next;next=(next+1)%N;const j=i*3; pos[j]=x;pos[j+1]=y;pos[j+2]=z;vel[j]=vx;vel[j+1]=vy;vel[j+2]=vz;col[j]=r;col[j+1]=gc;col[j+2]=b; - life[i]=max[i]=lf;s0[i]=sz0;s1[i]=sz1;a0[i]=a;aux[j+2]=add;grav[i]=gv||0; + colDirty=true;life[i]=max[i]=lf;s0[i]=sz0;s1[i]=sz1;a0[i]=a;aux[j+2]=add;grav[i]=gv||0; } function update(dt){ for(let i=0;iMatch over vel[j+1]-=grav[i]*dt;pos[j]+=vel[j]*dt;pos[j+1]+=vel[j+1]*dt;pos[j+2]+=vel[j+2]*dt; aux[j]=s0[i]+(s1[i]-s0[i])*u;aux[j+1]=a0[i]*(1-u)*(u<.08?u/.08:1); } - aP.needsUpdate=aC.needsUpdate=aA.needsUpdate=true; + aP.needsUpdate=aA.needsUpdate=true;if(colDirty){aC.needsUpdate=true;colDirty=false} mat.uniforms.sc.value=renderer.domElement.height/(2*Math.tan(camera.fov*Math.PI/360)); } // tracers @@ -789,19 +803,24 @@

Match over

// Dart: a delta-wing jet with canards PLANE_GEO.push({body:mergeGeo([tube(.8,.7,11,8),at(wingGeo(12.5,5.6,.22,4.2,.1,.8),0,-.15,-.9),at(wingGeo(4.4,1.2,.14,.8,.1,.5),0,.25,3.3),fin(2.6,2.6,0,-4.2)]), trim:mergeGeo([at(cone(.8,3.2,8),0,0,7.1),glass(0,.7,1.6,.55,.5,1.7),at(tube(.62,.5,1,8),0,0,-5.8)]),prop:0,propR:0,tip:6.1,tail:-6.2}); - for(const p of PLANE_GEO){p.body.scale(1.15,1.15,1.15);p.trim.scale(1.15,1.15,1.15);p.tip*=1.15;p.tail*=1.15;p.prop*=1.15;p.propR*=1.15} + for(const p of PLANE_GEO){p.body.scale(PLANE_SIZE,PLANE_SIZE,PLANE_SIZE);p.trim.scale(PLANE_SIZE,PLANE_SIZE,PLANE_SIZE);p.tip*=PLANE_SIZE;p.tail*=PLANE_SIZE;p.prop*=PLANE_SIZE;p.propR*=PLANE_SIZE} })(); const TRIM_MAT=new THREE.MeshLambertMaterial({color:0x23324a,emissive:0x0a1220}); const PROP_MAT=new THREE.MeshBasicMaterial({color:0xdfe8f2,transparent:true,opacity:.28,side:THREE.DoubleSide,depthWrite:false}); const SHIELD_MAT=new THREE.MeshBasicMaterial({color:0x9fe3ff,transparent:true,opacity:.13,depthWrite:false}); -const SHIELD_GEO=new THREE.SphereGeometry(9,14,10),PROP_GEO=new THREE.CircleGeometry(1,14); +const SHIELD_GEO=new THREE.SphereGeometry(9*1.12,14,10),PROP_GEO=new THREE.CircleGeometry(1,14); +// Every plane is drawn through instanced meshes: one body and one trim per airframe, one for all the propellers and +// one for the spawn shields, so 8 planes cost at most 10 draw calls instead of 3 or 4 each. e.mesh only holds where +// a plane is (position, YXZ rotation, scale); drawEnts copies that into the instances every frame. +const PLANE_MAX=16,BODY_MAT=new THREE.MeshLambertMaterial({color:0xffffff}); +// (the colour buffer is made by the first setColorAt, sized by count, so count only drops to 0 after that) +const instMesh=(geo,mat,n,col)=>{const m=new THREE.InstancedMesh(geo,mat,n);m.instanceMatrix.setUsage(THREE.DynamicDrawUsage);m.frustumCulled=false; + if(col){const c=new THREE.Color(1,1,1);for(let i=0;i({body:instMesh(pg.body,BODY_MAT,PLANE_MAX,true),trim:instMesh(pg.trim,TRIM_MAT,PLANE_MAX,false)})); +const PROP_INST=instMesh(PROP_GEO,PROP_MAT,PLANE_MAX,false),SHIELD_INST=instMesh(SHIELD_GEO,SHIELD_MAT,PLANE_MAX,false); function makeMesh(e){ - const pg=PLANE_GEO[e.frame],grp=new THREE.Group(); - const body=new THREE.Mesh(pg.body,new THREE.MeshLambertMaterial({color:new THREE.Color(entColor(e)),emissive:0x000000}));grp.add(body); - grp.add(new THREE.Mesh(pg.trim,TRIM_MAT)); - if(pg.prop){const pr=new THREE.Mesh(PROP_GEO,PROP_MAT);pr.position.z=pg.prop;pr.scale.setScalar(pg.propR);grp.add(pr)} - const sh=new THREE.Mesh(SHIELD_GEO,SHIELD_MAT);sh.visible=false;grp.add(sh); - grp.rotation.order='YXZ';grp.visible=false;grp.userData={body,sh,col:entColor(e)};scene.add(grp);return grp; + const grp=new THREE.Object3D(); + grp.rotation.order='YXZ';grp.visible=false;grp.userData={col:'',c3:new THREE.Color(),propA:0};return grp; } function entColor(e){return e.team>=0?TEAM_COL[e.team]:e.color} @@ -813,8 +832,8 @@

Match over

ctl:{boost:false,fire:false,roll:0},ai:null,lag:null,snaps:[],mesh:null,vscale:1,seenT:0}; e.mesh=makeMesh(e);G.ents.set(id,e);return e; } -function dropEnt(e){if(e.mesh){scene.remove(e.mesh);e.mesh.userData.body.material.dispose()}G.ents.delete(e.id);if(G.tgt===e)G.tgt=null;if(G.spec===e)G.spec=null} -function clearEnts(){for(const e of [...G.ents.values()])dropEnt(e);G.me=null;G.tgt=null;G.spec=null;for(const m of G.missiles)scene.remove(m.mesh);G.missiles.length=0;for(const f of G.flares)f.life=0;G.flares.length=0;FX.clear()} +function dropEnt(e){G.ents.delete(e.id);if(G.tgt===e)G.tgt=null;if(G.spec===e)G.spec=null} +function clearEnts(){for(const e of [...G.ents.values()])dropEnt(e);G.me=null;G.tgt=null;G.spec=null;G.missiles.length=0;for(const f of G.flares)f.life=0;G.flares.length=0;FX.clear()} function enemies(a,b){return a!==b&&(a.team<0||a.team!==b.team)} // ---------- spawning ---------- @@ -880,9 +899,9 @@

Match over

if(e===G.me)sfx('gun');else sfx('gunfar',e.pos); } // Bullets this browser owns (mine and my bots') decide their own hits against where the other planes are drawn. -const hitAcc=new Map();let hitFlushT=0; +const hitAcc=new Map(),ENTS=[];let hitFlushT=0; function updateBullets(dt){ - const live=simLive(); + const live=simLive(),ents=ENTS;ents.length=0;for(const e of G.ents.values())ents.push(e); // one list per frame, not an iterator per bullet for(const b of FX.bullets){ if(!b.on)continue; const x0=b.x,y0=b.y,z0=b.z,dx=b.vx*dt,dy=b.vy*dt,dz=b.vz*dt; @@ -892,7 +911,7 @@

Match over

if(!b.local||!live)continue; const by=G.ents.get(b.by);if(!by){continue} const L2=dx*dx+dy*dy+dz*dz; - for(const t of G.ents.values()){ + for(let n=0;nMatch over addMissile({id:ev.mid.slice(0,60),by:by.id,to:String(ev.to||''),local:false},by);break} case 'x':{const i=G.missiles.findIndex(m=>m.id===ev.mid);if(i<0)break;const m=G.missiles[i]; if(!mine&&finN(ev.x)&&finN(ev.y)&&finN(ev.z))m.pos.set(ev.x,ev.y,ev.z); - boom(m.pos,ev.r===1);scene.remove(m.mesh);G.missiles.splice(i,1);break} + boom(m.pos,ev.r===1);G.missiles.splice(i,1);break} case 'c':{const m=G.missiles.find(q=>q.id===ev.mid);if(m&&!m.local){m.to='';m.life=Math.min(m.life,1.6)}break} case 'f':{const by=G.ents.get(ev.by);if(!by)break; if(!mine)dropFlareFx(by); @@ -946,11 +965,11 @@

Match over

// ---------- missiles and flares ---------- const MSL_GEO=(function(){const b=new THREE.CylinderGeometry(.5,.5,6,6);b.rotateX(Math.PI/2);const n=new THREE.ConeGeometry(.5,1.6,6);n.rotateX(Math.PI/2);n.translate(0,0,3.8);return mergeGeo([b,n])})(); -const MSL_MAT=new THREE.MeshLambertMaterial({color:0xf4f6fa,emissive:0x553322}); +const MSL_MAT=new THREE.MeshLambertMaterial({color:0xf4f6fa,emissive:0x553322}),MSL_MAX_DRAWN=48,MSL_INST=instMesh(MSL_GEO,MSL_MAT,MSL_MAX_DRAWN,false); let mslSeq=0; function addMissile(m,by){ m.pos=by.pos.clone();m.pos.y-=2.5;m.dir=by.fwd.clone();m.speed=by.speed+50;m.life=MSL_LIFE;m.decoy=null;m.rollChk=false;m.smT=0; - m.mesh=new THREE.Mesh(MSL_GEO,MSL_MAT);m.mesh.scale.setScalar(1.6);scene.add(m.mesh);G.missiles.push(m); + m.mesh=new THREE.Object3D();m.mesh.scale.setScalar(1.6);m.mesh.position.copy(m.pos);G.missiles.push(m); // drawn by drawEnts (MSL_INST) sfx('missile',m.pos); if(G.me&&m.to===G.me.id){sfx('warn')} } @@ -984,7 +1003,7 @@

Match over

m.mesh.position.copy(m.pos);T2.copy(m.pos).add(m.dir);m.mesh.lookAt(T2); m.smT-=dt;if(m.smT<=0){m.smT=FX.low()?.05:.028;FX.puff(m.pos.x-m.dir.x*5,m.pos.y-m.dir.y*5,m.pos.z-m.dir.z*5,rand(-2,2),rand(-2,2),rand(-2,2),1.1,3.5,9,.93,.93,.95,.5,0,0);FX.puff(m.pos.x-m.dir.x*4,m.pos.y-m.dir.y*4,m.pos.z-m.dir.z*4,0,0,0,.09,7,4,1,.7,.3,1,1,0)} if(m.local){if(m.life<=0||m.pos.y0&&G.incoming===0)sfx('warn'); G.incoming=inc; @@ -1003,16 +1022,19 @@

Match over

// ---------- pickups: rings to fly through ---------- const PICK_RGB=[[.3,.86,.48],[1,.6,.16],[.95,.97,1]],PICK_HEX=[0x4ddc7a,0xff9a2a,0xf2f6ff],PICK_NAME=['Repairs','Missiles','Flares']; +// All twelve rings are two instanced meshes (the rings, and the gems in them), so they cost 2 draw calls, not 24. +const PICK_RING=instMesh(new THREE.TorusGeometry(17,1.7,8,28),new THREE.MeshBasicMaterial({color:0xffffff,fog:false}),12,true); +const PICK_CORE=instMesh(new THREE.OctahedronGeometry(4),new THREE.MeshBasicMaterial({color:0xffffff}),12,true); const PICKS=[[-900,-620,170],[1040,-60,70],[-1500,420,190],[810,-1350,75],[-560,1300,170],[1395,1170,80],[0,0,330],[1470,-530,75],[-1750,-1250,200],[515,945,75],[-320,-1750,180],[-1150,1750,200]].map((q,i)=>{ const kind=i%3,y=Math.max(groundH(q[0],q[1]),0)+q[2]; - const mesh=new THREE.Mesh(new THREE.TorusGeometry(17,1.7,8,28),new THREE.MeshBasicMaterial({color:PICK_HEX[kind],fog:false}));mesh.position.set(q[0],y,q[1]);scene.add(mesh); - const core=new THREE.Mesh(new THREE.OctahedronGeometry(4),new THREE.MeshBasicMaterial({color:PICK_HEX[kind]}));mesh.add(core); - return {x:q[0],y,z:q[1],kind,until:0,mesh,i}; + const mesh=new THREE.Object3D();mesh.position.set(q[0],y,q[1]); + return {x:q[0],y,z:q[1],kind,until:0,mesh,i,c3:new THREE.Color(PICK_HEX[kind])}; }); function updatePicks(dt){ - const now=netNow(),live=G.phase==='play'; + const now=netNow(),live=G.phase==='play';let np=0; for(const p of PICKS){ const on=now>=p.until;p.mesh.visible=on;if(!on)continue;p.mesh.rotation.y+=dt*1.2; + p.mesh.updateMatrix();PICK_RING.setMatrixAt(np,p.mesh.matrix);PICK_CORE.setMatrixAt(np,p.mesh.matrix);PICK_RING.setColorAt(np,p.c3);PICK_CORE.setColorAt(np,p.c3);np++; if(!live)continue; for(const e of G.ents.values()){ if(!e.local||!e.alive)continue;const dx=e.pos.x-p.x,dy=e.pos.y-p.y,dz=e.pos.z-p.z; @@ -1023,6 +1045,7 @@

Match over

} } } + PICK_RING.count=PICK_CORE.count=np;PICK_RING.visible=PICK_CORE.visible=np>0;PICK_RING.instanceMatrix.needsUpdate=PICK_CORE.instanceMatrix.needsUpdate=PICK_RING.instanceColor.needsUpdate=PICK_CORE.instanceColor.needsUpdate=true; } // ===================================================================== @@ -1087,7 +1110,7 @@

Match over

} // ---------- planes other browsers fly ---------- -const SMP={x:0,y:0,z:0,h:0,p:0,r:0}; +const SMP={x:0,y:0,z:0,h:0,p:0,r:0},SMP_LIN=['x','y','z'],SMP_ANG=['h','p','r']; function pushSnap(e,ts,x,y,z,h,p,r,now){ if(!e.lag){e.lag=NetSmooth.lag();e.snaps=[]} if(!e.lag.note(ts,now))return; @@ -1097,21 +1120,27 @@

Match over

} function sampleRemote(e,dt,now){ if(!e.lag||!e.snaps.length)return; - NetSmooth.sample(e.snaps,e.lag.time(now),SMP,['x','y','z'],['h','p','r']); + NetSmooth.sample(e.snaps,e.lag.time(now),SMP,SMP_LIN,SMP_ANG); e.pos.set(SMP.x,SMP.y,SMP.z);e.h=SMP.h;e.p=SMP.p;e.r=SMP.r;dirOf(e.h,e.p,e.fwd);e.vel.copy(e.fwd).multiplyScalar(e.speed); if(e.alive&&e.firing){e.gunT-=dt;let n=0;while(e.gunT<=0&&n++<3){e.gunT+=GUN_RATE;shoot(e,false)}}else e.gunT=0; } // ---------- drawing the planes, their trails and smoke ---------- +const PM=new THREE.Matrix4(),PM2=new THREE.Matrix4(); function drawEnts(dt){ const cp=camera.position; + for(const q of PLANE_INST){q.body.count=q.trim.count=0} + let np=0,ns=0; for(const e of G.ents.values()){ const m=e.mesh,show=e.alive&&!e.out;m.visible=show;if(!show)continue; const d=e.pos.distanceTo(cp);e.vscale=e===G.me?1:clamp(d/260,1,3); - m.position.copy(e.pos);m.rotation.set(-e.p,e.h,e.r);m.scale.setScalar(e.vscale); - const u=m.userData,col=entColor(e);if(u.col!==col){u.col=col;u.body.material.color.set(col)} - u.sh.visible=e.shield>0; - const pr=m.children[2];if(pr&&pr!==u.sh)pr.rotation.z+=dt*40; + m.position.copy(e.pos);m.rotation.set(-e.p,e.h,e.r);m.scale.setScalar(e.vscale);m.updateMatrix(); + const u=m.userData,col=entColor(e);if(u.col!==col){u.col=col;u.c3.set(col)} + const q=PLANE_INST[e.frame],k=q.body.count; + if(k0&&ns0||d>2600)continue;e.trailT=FX.low()?.07:.035; const pg=PLANE_GEO[e.frame],cr=Math.cos(e.r),sr=Math.sin(e.r),rx=-Math.cos(e.h),rz=Math.sin(e.h); if(e.speed>112||e.boosting||Math.abs(e.yr)>.75){ @@ -1123,6 +1152,12 @@

Match over

if(e.boosting)FX.puff(e.pos.x+e.fwd.x*pg.tail,e.pos.y+e.fwd.y*pg.tail,e.pos.z+e.fwd.z*pg.tail,0,0,0,.14,7,3,1,.72,.3,1,1,0); if(e.hp<45)FX.puff(e.pos.x+e.fwd.x*pg.tail*.5,e.pos.y,e.pos.z+e.fwd.z*pg.tail*.5,rand(-3,3),rand(2,8),rand(-3,3),e.hp<22?2.2:1.4,4,e.hp<22?16:11,.16,.16,.18,.55,0,0); } + // an instanced mesh with nothing in it is hidden, so it costs no draw call + for(const q of PLANE_INST){const on=q.body.count>0;q.body.visible=q.trim.visible=on;if(on){q.body.instanceMatrix.needsUpdate=q.body.instanceColor.needsUpdate=q.trim.instanceMatrix.needsUpdate=true}} + PROP_INST.count=np;PROP_INST.visible=np>0;if(np)PROP_INST.instanceMatrix.needsUpdate=true;SHIELD_INST.count=ns;SHIELD_INST.visible=ns>0;if(ns)SHIELD_INST.instanceMatrix.needsUpdate=true; + // missiles: one instanced mesh for all of them + let nm=0;for(const ms of G.missiles){if(nm>=MSL_MAX_DRAWN)break;ms.mesh.updateMatrix();MSL_INST.setMatrixAt(nm++,ms.mesh.matrix)} + MSL_INST.count=nm;MSL_INST.visible=nm>0;if(nm)MSL_INST.instanceMatrix.needsUpdate=true; } // ===================================================================== @@ -1331,8 +1366,8 @@

Match over

lobbyDirty=true; } function beginMatch(){ - const rs=G.rs;G.matchId=rs.id;G.phase='play';G.ended=false;G.paused=false;setSky(rs.sky); - for(const m of G.missiles)scene.remove(m.mesh);G.missiles.length=0;G.flares.length=0;hitAcc.clear(); + const rs=G.rs;G.matchId=rs.id;G.phase='play';G.flewFrom=Math.max(netNow(),rs.t0);G.ended=false;G.paused=false;setSky(rs.sky); + G.missiles.length=0;G.flares.length=0;hitAcc.clear(); let i=0; for(const e of G.ents.values())if(e.local){e.kills=0;e.deaths=0;e.alive=false;e.respT=.05+(e.bot?.12*(++i):0);e.mesh.visible=false} for(const p of PICKS)p.until=0; @@ -1357,9 +1392,47 @@

Match over

$('endTitle').textContent=me&&me.out?'Match over':draw?'Draw':won?'Victory':'Shot down'; $('endSub').textContent=draw?'Nobody came out ahead.':won?(rs.md===2?'Your team wins.':'You win the match.'):rs.md===2?TX(who+' team wins.'):TX('{w} wins the match.',{w:who}); $('endTable').innerHTML=tableHTML(); + rateMatch(rs,me,won); $('end').hidden=false;$('touch').hidden=true;$('pause').hidden=true; sfx(won?'win':'lose');showAd('adEnd');endButtons(); } +// ---------- ranked rating (../elo.js) ---------- +// Only online matches count, against the other real pilots who were flying at the end (bots and teammates don't), and +// only if you flew at least a minute of the match, or were there from the start of one that ended on the kill target. +// A free-for-all goes by the final standings (kills, then fewer losses; equal both is a draw); a duel and 2v2 by the result. +const RANK_MIN=60000; +let rankView=null; +// The match can end (the host's rs) a moment before the last scores arrive from the other browsers, so the rating +// waits RANK_SETTLE for them (and redraws the standings with them) before it is worked out. +const RANK_SETTLE=1500; +function rateMatch(rs,me,won){ + rankView=null; + if(G.online&&me&&!me.out&&window.BackRoomElo){rankView={wait:true};setTimeout(()=>rateNow(rs,me,won),RANK_SETTLE)} + showRank(); +} +function rateNow(rs,me,won){ + if(G.matchId!==rs.id||!rankView||!rankView.wait)return; + if(G.phase==='end'&&!$('end').hidden)$('endTable').innerHTML=tableHTML(); + const opp=[...G.ents.values()].filter(e=>e!==me&&!e.out&&enemies(me,e)),humans=opp.filter(e=>!e.bot).length; + // ended before the clock ran out: someone reached the kill target + const end=rs.et||netNow(),from=G.flewFrom||end,full=end-rs.t0rs.md!==1?(rs.win?(won?1:0):.5):rs.win===me.id?1:rs.win===e.id?0:me.kills!==e.kills?(me.kills>e.kills?1:0):me.deaths!==e.deaths?(me.deathse.bot?{bot:1,s:res(e)}:{u:e.id,s:res(e)})}).then(r=>{if(G.matchId!==rs.id)return;rankView=r?{r}:null;showRank()},()=>{rankView=null;showRank()})}catch(e){rankView=null} + } + showRank(); +} +function showRank(){ + const el=$('endRank'),v=rankView;el.hidden=!v;if(!v)return;el.textContent=''; + if(v.why){el.textContent=TX(v.why);return} + if(v.wait){el.textContent=TX('Ranked match: working out your rating…');return} + const r=v.r,b=document.createElement('b'),d=document.createElement('span'),sm=document.createElement('small'); + b.textContent=r.after;d.className=r.delta>0?'up':r.delta<0?'dn':'';d.textContent=' ('+(r.delta>0?'+':r.delta<0?'−':'±')+Math.abs(r.delta)+')'; + el.append(TX('Ranked rating')+' ',b,d);sm.textContent=TX(r.humans>1?'Rated against {n} other pilots':'Rated against 1 other pilot',{n:r.humans});el.appendChild(sm); +} function endButtons(){ const b=$('again'),host=isHost(); if(!G.online){b.disabled=false;b.textContent='Fly again';$('endMsg').textContent=''} @@ -1537,7 +1610,7 @@

Match over

camera.updateMatrixWorld(); // inside a cloud everything goes white let w=0;const p=camera.position; - for(const b of cloudBlobs){const dx=(p.x-b[0])/b[3],dy=(p.y-b[1])/b[4],dz=(p.z-b[2])/b[5],q=dx*dx+dy*dy+dz*dz;if(q<1){w=Math.max(w,1-q)}} + if(p.y>CLOUD_Y0&&p.y=1||dy<=-1)continue;const dx=(p.x-b[0])/b[3],dz=(p.z-b[2])/b[5],q=dx*dx+dy*dy+dz*dz;if(q<1&&1-q>w)w=1-q} G.white+=(Math.min(.82,w*1.6)-G.white)*Math.min(1,dt*6); skyDome.position.copy(p); } @@ -1550,10 +1623,14 @@

Match over

T1.copy(v).applyMatrix4(camera.matrixWorldInverse);const f=(VH/2)/Math.tan(camera.fov*Math.PI/360); SC.cx=T1.x;SC.cy=T1.y;SC.front=T1.z<-1;const z=Math.max(-T1.z,1);SC.x=VW/2+T1.x/z*f;SC.y=VH/2-T1.y/z*f;return SC; } -const put=(el,x,y)=>{el.style.transform='translate('+x.toFixed(1)+'px,'+y.toFixed(1)+'px)'}; +// HUD writes only go to the page when the value changed (half-pixel steps for positions), so a still HUD costs nothing. +const put=(el,x,y)=>{x=Math.round(x*2);y=Math.round(y*2);if(el._x===x&&el._y===y)return;el._x=x;el._y=y;el.style.transform='translate('+x/2+'px,'+y/2+'px)'}; +const setOp=(el,v)=>{if(el._o!==v){el._o=v;el.style.opacity=v}}; +const setBar=(el,v)=>{v=Math.round(v*500);if(el._b!==v){el._b=v;el.style.transform='scaleX('+v/500+')'}}; const marks=[]; (function(){const box=$('marks');for(let i=0;i<8;i++){const d=document.createElement('div');d.className='mark';d.hidden=true;d.innerHTML='';box.appendChild(d);marks.push({el:d,name:d.querySelector('span'),hp:d.querySelector('i'),txt:'',hpv:-1,cls:''})}})(); let hudT=0,bannerT=0,hitT=0; +const HE={};for(const id of ['vign','white','reticle','nose','lead','lockRing','hpF','boF','heF'])HE[id]=$(id); function banner(t,sub,ms){const b=$('banner');b.textContent=TX(t);if(sub){const s=document.createElement('small');s.textContent=TX(sub);b.appendChild(s)}b.classList.add('on');bannerT=(ms||1500)/1000} function hitMark(){hitT=.12;$('hitm').classList.add('on')} function feedLine(by,v,w){ @@ -1571,11 +1648,11 @@

Match over

if(bannerT>0){bannerT-=dt;if(bannerT<=0)$('banner').classList.remove('on')} if(hitT>0){hitT-=dt;if(hitT<=0)$('hitm').classList.remove('on')} G.hurtFlash=Math.max(0,G.hurtFlash-dt*1.6); - $('vign').style.opacity=(fly?Math.max(G.hurtFlash,me.hp<30?.35:0):0).toFixed(2); - $('white').style.opacity=G.white.toFixed(2); + setOp(HE.vign,(fly?Math.max(G.hurtFlash,me.hp<30?.35:0):0).toFixed(2)); + setOp(HE.white,G.white.toFixed(2)); // aim ring, gun cross, lead diamond, lock ring - const ret=$('reticle'),nose=$('nose'),lead=$('lead'),lr=$('lockRing'); - ret.hidden=nose.hidden=!fly; + const ret=HE.reticle,nose=HE.nose,lead=HE.lead,lr=HE.lockRing; + if(ret.hidden===fly)ret.hidden=nose.hidden=!fly; let tg=fly?G.tgt:null;if(tg&&!tg.alive)tg=null; let nx=0,ny=0,leadOn=false; if(fly){ @@ -1588,7 +1665,7 @@

Match over

s=toScreen(T3);if(s.front){leadOn=true;put(lead,s.x,s.y);lead.classList.toggle('on',Math.hypot(s.x-nx,s.y-ny)<16)}} } } - lead.hidden=!leadOn; + if(lead.hidden===leadOn)lead.hidden=!leadOn; // boxes round the other planes, arrows for the ones off screen let mi=0;const edge=Math.min(VW,VH)*.4; if(G.phase==='play'&&G.mode!=='menu')for(const e of G.ents.values()){ @@ -1597,21 +1674,21 @@

Match over

const on=s.front&&s.x>10&&s.x10&&s.y1300))continue; mi++;let cls='mark'+(foe?'':' fr')+(isT?' tg':'')+(on?'':' off'); - if(on){const sz=clamp(2600/d,24,64);m.el.style.width=m.el.style.height=sz.toFixed(0)+'px';m.el.style.margin=(-sz/2).toFixed(0)+'px 0 0 '+(-sz/2).toFixed(0)+'px';put(m.el,s.x,s.y)} - else{let ax=s.cx,ay=-s.cy;if(!s.front&&Math.hypot(ax,ay)<1e-3)ay=1;const a=Math.atan2(ay,ax);m.el.style.width=m.el.style.height='';m.el.style.margin='';m.el.style.setProperty('--a',(a*57.2958).toFixed(0)+'deg');put(m.el,VW/2+Math.cos(a)*edge,VH/2+Math.sin(a)*edge)} + if(on){const sz=Math.round(clamp(2600*1.12/d,24,72));if(m.sz!==sz){m.sz=sz;m.el.style.width=m.el.style.height=sz+'px';m.el.style.margin=(-sz/2).toFixed(0)+'px 0 0 '+(-sz/2).toFixed(0)+'px'}put(m.el,s.x,s.y)} + else{let ax=s.cx,ay=-s.cy;if(!s.front&&Math.hypot(ax,ay)<1e-3)ay=1;const a=Math.atan2(ay,ax),deg=Math.round(a*57.2958);if(m.sz!==0){m.sz=0;m.el.style.width=m.el.style.height='';m.el.style.margin=''}if(m.deg!==deg){m.deg=deg;m.el.style.setProperty('--a',deg+'deg')}put(m.el,VW/2+Math.cos(a)*edge,VH/2+Math.sin(a)*edge)} if(m.cls!==cls){m.cls=cls;m.el.className=cls} - const txt=e.name+' '+Math.round(d/10)*10+'m';if(m.txt!==txt){m.txt=txt;m.name.textContent=txt} + const dm=Math.round(d/10)*10;if(m.e!==e||m.dm!==dm||m.nm!==e.name){m.e=e;m.dm=dm;m.nm=e.name;m.name.textContent=e.name+' '+dm+'m'} const hv=Math.round(e.hp/5);if(m.hpv!==hv){m.hpv=hv;m.hp.style.width=clamp(e.hp,0,100)+'%'} - m.el.hidden=false; + if(m.el.hidden)m.el.hidden=false; if(isT){ const lk=fly&&me.lock.id===e.id?me.lock.t/LOCK_T:0; - if(lk>0&&on){lr.hidden=false;put(lr,s.x,s.y);const full=lk>=1;lr.classList.toggle('locked',full);const lt=TX(full?'LOCKED':'LOCKING');if(lr.firstElementChild.textContent!==lt)lr.firstElementChild.textContent=lt;lr.style.opacity=full?1:(.4+lk*.6).toFixed(2)}else lr.hidden=true; + if(lk>0&&on){lr.hidden=false;put(lr,s.x,s.y);const full=lk>=1;lr.classList.toggle('locked',full);const lt=TX(full?'LOCKED':'LOCKING');if(lr.firstElementChild.textContent!==lt)lr.firstElementChild.textContent=lt;setOp(lr,full?'1':(.4+lk*.6).toFixed(2))}else if(!lr.hidden)lr.hidden=true; } } - if(!tg)lr.hidden=true; + if(!tg&&!lr.hidden)lr.hidden=true; for(let i=mi;i0)return;hudT=.12; if(touch.fill&&me)touch.fill.style.height=(me.thr*100).toFixed(0)+'%'; const now=netNow(); @@ -1815,7 +1892,7 @@

Match over

else $('room').value=store.get('room','')||''; if(touchUI)setTouch(true); // English / Español switched (lang.js): redo what this page put together itself (fixed text switches by itself) - document.addEventListener('backroom:lang',()=>{$('warn').dataset.k='';if(G.online&&G.phase==='lobby')renderLobby();if(G.phase==='end'&&$('end').hidden===false)$('endTable').innerHTML=tableHTML()}); + document.addEventListener('backroom:lang',()=>{$('warn').dataset.k='';if(G.online&&G.phase==='lobby')renderLobby();if(G.phase==='end'&&$('end').hidden===false){$('endTable').innerHTML=tableHTML();showRank()}}); addEventListener('pointerdown',initAudio,{once:true}); })(); @@ -1850,7 +1927,7 @@

Match over

setSky(0);showMenu();requestAnimationFrame(frame); addEventListener('pagehide',()=>{if(G.online)Net.leave()}); // A hook for automated tests only (browsers driven by a test tool say so with navigator.webdriver). -if(navigator.webdriver)window.__skd={ff(s){for(let i=0;i diff --git a/e63334287a3deaa3/stats.js b/e63334287a3deaa3/stats.js index f5c6f750..fb6bbab7 100644 --- a/e63334287a3deaa3/stats.js +++ b/e63334287a3deaa3/stats.js @@ -525,7 +525,7 @@ function googleUser(u, uid) { return u && u.uid === uid && u.isAnonymous === false ? u : null; } // Ranked ratings from elo.js ('elo:' in this browser) become the game's 'elo' stat, once a rated match has been played. - ['boostball', 'rumble-karts', 'backrooms-1v1', 'drop-zone', 'odd-one-out', 'puffer-party', 'turbo-trail', 'lunge-line', 'deepword', 'tumble-trials', 'slipstream', 'chromaflage'].forEach(function (g) { + ['boostball', 'rumble-karts', 'backrooms-1v1', 'drop-zone', 'odd-one-out', 'puffer-party', 'turbo-trail', 'lunge-line', 'deepword', 'tumble-trials', 'slipstream', 'chromaflage', 'sky-duel'].forEach(function (g) { var prev = READ[g]; READ[g] = function () { var o = (prev && prev()) || {}, r = sj('elo:' + g); if (r && (r.g | 0) > 0) o.elo = Math.round(num(r.r)); return o; }; });