You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit 73752f6
Browse filesBrowse the repository at this point in the historyBrowse files
Replay clips for Slipstream, Boostball and Driftfall (#355)
- **New: replay clips** in Slipstream, Boostball and Driftfall. While a race or match is on, the game is recorded in the browser. When it ends, the last ~15–20 s becomes one video (MP4 where the browser supports it) with an "ascoding11.com/<game>" watermark and a 2.5 s end card, "Play this game now ▶ ascoding11.com/<game>".
- A panel offers **Share replay** (phone share sheet), **Save video** and **Copy game link**, plus **Turn off replays**. Nothing is uploaded; no server or storage needed.
- **Frame rate protected:** if recording is what's slowing a game (checked by pausing it for 4 s when the game drops under 45 fps), clips switch off for that visit.
- Files: new `e63334287a3deaa3/replay.js`; one script tag and three one-line calls (`start` / `end` / `stop`) in each of `slipstream/`, `boostball/` and `drop-zone/index.html`; README; What's new.
- Tested here: a full Boostball practice match makes a working 24 s H.264 clip with the watermark and end card. **Not yet tested on a real school laptop or phone**; frame times in the test container are software-rendered and mean nothing. Worth playing a match on a Chromebook to confirm it stays smooth.
Claude-Session: https://claude.ai/code/session_016ZY4GY6KEVGmw5xYZiPbvp
Co-authored-by: Claude <noreply@anthropic.com>
Copy file name to clipboardExpand all lines: README.md
+1Lines changed: 1 addition & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -144,6 +144,7 @@ Personal site hosted with GitHub Pages at **https://ascoding11.github.io**, the
144
144
- `e63334287a3deaa3/layout.js`: Edit layout (Back Room). Each player can put the page's big blocks in their own order, and choose which games have big cards. It's loaded with one `<script defer>` in the `<head>` of the Back Room page and the phone page, and the home page's `reveal()` loads it too. A small "Edit layout" button sits at the top of the games: on the Back Room page it's in the Games section's top padding, and on the phone page it's in a slim row above the first heading. It opens an editor where every movable block is a bar (its icon or thumbnail, name and a short line) with a drag handle and ↑/↓ buttons. With a mouse you can drag anywhere on a bar. On touch you drag by the handle, so the list still scrolls, and it scrolls by itself near the edges. The arrow keys also work on the handle, and a line shows where the bar will land. The blocks themselves are hidden while editing (`html.lay-editing`). **Done** saves the order and redraws the page. **Reset** puts the default order back and saves that. The editor has two tabs, **Order** (the bars) and **Game sizes**. Game sizes shows each section's games as tiles (thumbnail, name and a Big/Small label) in the section's own number of columns at the current screen width, so it's a live preview of how the rows will come out. Tapping a tile switches it between big and small (switching a game back to the size the site gives it forgets the choice), and each section has **All small**, **All big** and **Default** (back to the site's sizes); Reset on this tab puts every game back. On the Back Room page (and the home page's copy) big means `wide` + `pw` (two columns on computers, a whole row on phones) and small means neither; a game the player hasn't chosen keeps the classes the HTML gives it, so a new game still gets the size Arjun gives it. On the phone page big is `.lay-big`, and every tile is small by default. The puzzle tiles aren't sized (but they're kept even, below). A game's key is its folder, read from the card's links (or the tile's `thumbs/<folder>.jpg`), so every card, including new ones, is picked up by itself, and a game on both pages shares one entry. **Even rows** (for every player, whether or not they've chosen sizes): big and small are only wishes, and layout.js has the last word on which cards are wide so every row ends flush. For each grid (the Back Room's `.gc-grid` and `.pz-grid`, the phone page's `.grid`) it counts the cards that are showing (the search hides some with `.gs-hide`), reads the most columns the CSS allows at this width (`--ev-max`, from `games.css` or the phone page's styles), and `evPlan()` tries every column count up to that, keeping the plan with the fewest cards changed from their wished size plus 2 for each column fewer than the most, then the fewest rows, the fewest wide cards and wide cards nearer the top. Cards never change order. It writes `--ev-cols` (inline) and `data-ev` on the grid and `data-ev-w` on each wide card, never classes, and a MutationObserver on class changes and added or removed cards runs it again, as does crossing a `--ev-max` width and applying a saved order or sizes. Anything else in a grid that spans the whole row (`.pz-wrap` in Puzzles, the phone page's Daily Puzzles tile) splits it into parts that each end flush. The Game sizes tab previews the same plan (with every game showing); a tile that comes out another size than set there is dashed and marked "Evens the rows", with a note under the section. On the phone page a wide tile is a whole row upright and two of three columns sideways; puzzle tiles only stretch. The blocks on the Back Room page (and the home page's copy) are `party`, `online`, `daily` (only if the page has a Daily Puzzles card, `.gc-daily`; it hasn't since the puzzles became tiles, and a saved order that names it still loads), one per genre section (`puzzles`, `parkour`, `action`, `multi`, `solo`, taken from each `gs-<name>` class, so a new section is included by itself) and `leaderboards`. On the phone page they are `party`, `online`, every GROUPS row (`m-` + the row's name in lowercase with dashes) and `leaderboards`. Each run of rows of one mode gets that mode's heading, with the count for that run. The order is kept per browser in localStorage `layout:v1` = `{v: 1, order: [ids], size: {<game folder>: 'big'|'small'}}`, and it is also in account-nudge.js's synced keys, so the sizes sync with it. `size` is optional (older records without it still work, so no version bump) and only names the games the player chose; with only sizes saved, `order` is `[]`. Saving from one page keeps the sizes of games that are only on the other page. Both pages share one list: each page uses the ids it has, and when it saves, it keeps the other page's ids next to the block they followed. A block the list doesn't name (a new section, or a panel that hadn't loaded yet when the order was saved) goes to its default place. With no saved order (or the default order) and no sizes, the page isn't touched apart from the button, and the key is removed. How a different order is applied: on the Back Room page, the Party, Online and Leaderboards panels move inside `section.br-games` (`.lay-on`), because the genre sections need its styles. The blocks go there in order, with the "Want more games?" note after the last games block. If a page has a Daily Puzzles card and it isn't directly above Puzzles, it gets its own `<section class="gs gs-puzzles lay-daily">`, and Puzzles' count drops "+ daily". On the phone page, the rows and panels go into `.wrap` before `#lists`. party.js, social.js and leaderboard.js add their panels after layout.js runs, and social.js moves Online back under Party once. A MutationObserver on the wrap and the Games section (or `#lists`) puts any block that lands out of place back in order before the next paint. It only moves elements that are out of place, so it doesn't loop with news.js's own observer. **The row of game types** (`.gs-nav` on the Back Room page, `.gnav` on the phone page) isn't a block of its own in the editor: it belongs to the games. In the default order it stays where the page has it, at the top of the games, which is already under Online. In a player's own order it goes right above the first games block that comes after the Online panel, so it is never above Online or Party while there are games below them (before, it stayed at the top of the page, above Party and Online). If the player has put every games block above Online, or the page has no Online panel, it goes right above the first games block. Nothing about the saved record changed, so saved orders load as before and only the row of game types moves. The home page's `reveal()` copy is the default HTML, so layout.js rearranges it there in the same way. Nothing is stored online by this file.
145
145
- In-game leaderboards: every game page that loads stats.js gets a "Leaderboard" button that opens that game's boards in a panel over the page (the same boards, checks and data as the Leaderboards section of the Back Room page, which is unchanged). stats.js adds the button (`boardButton`) and, the first time it is pressed, loads `/namefilter.js` if the page hasn't and `leaderboard.js` with `data-game="<folder>"`: its game mode builds the usual section inside a dialog (`.lbd-modal`, with its own colours and type since game pages have none of the hub's CSS variables), fixed to that game, signed in through `BackRoomStats.conn()` (the connection stats.js already publishes with) instead of party.js, read when the panel opens, with the view remembered per game (`lb:view:<folder>`). Close, Escape or a press outside closes it; keys and presses inside stay inside. Where the button goes, so it never sits over play: in a game with a `#menu`, inside that menu as its last item, and while that menu is showing but its button is scrolled out of view (most menus are taller than the screen), a copy (`#brlb-pin`) is pinned bottom right and goes as soon as the real one scrolls into view, the menu is hidden or faded out, or the panel opens; on a page with no `#menu` and no canvas (the puzzles), at the end of the page; on a page with a canvas and no `#menu`, a small round button fixed bottom left that hides while the pointer is locked and for 8 s after any key or press. A game's stats.js tag can override it: `data-board="off"`, a corner (`tl`, `tr`, `bl`, `br`; 2048 uses `bl`), or `data-board-in="<css selector>"` to put it inside a chosen element. A new game with a `#menu` needs nothing. The button is added inside frames too (the home page, phone page and party layer all open games in an iframe, which is how most people play); only the hidden stats sidecar frame has no stats.js of its own.
146
146
- `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, Sky Duel and Blackwade. 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 (`<script src="/e63334287a3deaa3/elo.js" data-game="<folder>" defer></script>`) 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. Hush Pools is co-op, so it has no opponents in that sense: when an online party escapes, each player is compared with each teammate by what they did for the party (`runScore`: 10 a rescue, 4 a valve opened or the keypad solved, minus 6 for each time they went down), and the one with the higher score "beats" the other (equal is a draw). 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:<folder>` (`{ r, g, wn, pk, uid }`) and the Realtime Database at `rooms/elo-<folder>/players/<uid>` (`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:<folder>` 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.
147
+
- `e63334287a3deaa3/replay.js`: **replay clips** (Slipstream, Boostball and Driftfall so far). While a match or race is on, it records the game's canvas in the browser (`canvas.captureStream(30)` into a MediaRecorder, restarted every 6 s so each piece is a complete file; only the last 4 pieces are kept). When it ends, the newest pieces adding up to at least 15 s are played back into a 2D canvas (at most 1280 px wide) with a small "ascoding11.com/<game>" watermark and a 2.5 s end card, "Play this game now ▶ ascoding11.com/<game>", and recorded once more into one file (MP4/H.264 where the browser can, else WebM; video only). A panel (bottom-right on computers, near the top on phones) shows progress, then a looping preview with **Share replay** (share sheet with the video), **Save video** and **Copy game link**, and a **Turn off replays** link (localStorage `replay:on` = `'0'`). Nothing is uploaded. **Hooks in each game:** `<script src="/e63334287a3deaa3/replay.js" data-game="<folder>" defer>` next to elo.js, then `BackRoomReplay.start(canvas)` when play begins (Slipstream `beginRaceView`, Boostball `showHud` while playing, Driftfall `showHud`; calling it again does nothing), `BackRoomReplay.end()` at the results (Slipstream `showResults`, Boostball `endMatch`, Driftfall `showEnd`, so a knock-out gets its clip at once) and `BackRoomReplay.stop()` in `toMenu`. Practice matches get clips too. To add a game: the tag, the three calls, and its name and typed address in `NAMES`. **Frame rate first:** a light monitor counts frames while recording; under 45 fps it pauses recording for 4 s, and if the game then runs 8 fps or more faster, clips stay off for that visit (what was recorded is still offered). Otherwise that rate becomes the machine's baseline and it's only tested again if the rate drops 8 fps below it. Measured in a container (software graphics, so frame times mean nothing): draw calls, triangles and memory are unchanged; the recorder's restarts add a little script time every 6 s. Not yet measured on a real school laptop or phone.
147
148
- `e63334287a3deaa3/flex.js`: the rank-up share card (Back Room). `elo.js` loads it only after a rated match (`BackRoomElo.noFlex = true` turns it off for a game) and calls `BackRoomFlex.check()` with the match result. **Elo tiers:** Bronze (under 1100), Silver 1100, Gold 1250, Platinum 1400, Diamond 1600, Champion 1800 (`TIERS`). **Places:** it reads `rooms/elo-<folder>/players` once (through the game's own Firebase app) to work out the player's place among everyone rated in that game; the brackets are #1, top 3, top 10 and top 100 (`BRACKETS`), and a bracket only counts when the game has at least max(5, 2 × the bracket) rated players. A panel pops up at the bottom of the game when a match takes the player to a tier, or a bracket, higher than any already celebrated in that game (kept in localStorage `flex:<folder>` as `{ t, b }`, so bouncing over a line doesn't repeat it). It has **Share achievement** (the phone's share sheet with the picture and a line of text; the home page's game layer, the phone page's frame and the home page's phone frame allow `web-share` for this), **Save image** and **Copy link**, and closes by itself after 20 s (45 s once a button is used). The picture is drawn on a 1080 × 1350 canvas from the game's phone thumbnail (`m/thumbs/<folder>.jpg`): the game's name, RANK UP or NEW PERSONAL BEST, a shield in the tier's colours with the place or the tier's first letter, the tier, the place out of how many, the rating and change, the player's name and "Play at ascoding11.com/<game>" (the typed address; `GAMES` in the file maps each rated folder to its name and address). English or Spanish follows `lang.js`. `BackRoomFlex.preview('Gold')` or `preview(10)` shows the panel in any game page for testing. Shell Crackers keeps its own rating and doesn't get the card.
148
149
- `e63334287a3deaa3/netrelay.js`, `colyseus.js` and `netrelay-config.js`: the game relay. Online rooms of the games listed in `netrelay-config.js` (`RELAY_PREFIXES`, and Rumble Karts, whose rooms have no prefix) go through our own Colyseus server instead of the Firebase Realtime Database: the code is in the separate `ASCoding11/game-server` repo, hosted on Colyseus Cloud (US East, Newark) at the address in `netrelay-config.js`, and redeployed by every push to that repo's `main`. `netrelay.js` (copied from that repo's `client/`) wraps `firebase.database()` and looks like it, so a game only changes the line that makes its database: `NetRelay.database(firebase.database(), window.RELAY_ROOMS)`. **On the relay (20 Nov 2026):** the real-time games: Coil, Slipstream, Boostball, Kartwheel, Rumble Karts, Shell Crackers, Backrooms 1v1, Driftfall, Blockstorm, Sky Duel, Hail Mary, Updraft, Spire, Tumble Trials, Turbo Trail, Escapade, Chromaflage, Hush Pools, Putterby, Lokop and Lanternhold (Coil first, the rest the same evening). **Still on Firebase:** the turn-based and word games (Showdown, Deepword, Odd One Out, Puffer Party), Quarry (its worlds stay in the room for days), Rampline (boards and community tracks), and the shared nodes `sc-ratings`, `br-queue` and `hm-queue` (`KEEP_ON_FIREBASE`), which hold ratings and matchmaking across rooms. Only that game's `rooms/<prefix>-<code>` go to the relay; leaderboards, ratings, parties and the lobby stay on Firebase. Players still sign in with Firebase, and the relay checks their sign-in token. Relay rooms live in the server's memory, so they last while someone is in them and 2 minutes after; games that keep data in their room for days (Quarry's worlds) must stay on Firebase. `colyseus.js` is the Colyseus browser library (MIT). **Off switch:** blank the `url` in `netrelay-config.js` and every game goes back to Firebase at once. **One game back to Firebase:** take its prefix out of `RELAY_PREFIXES` (for Rumble Karts, set `RELAY_RUMBLE_KARTS` to false). **Moving another game over:** load the three files before its script, change its database line, add its prefix to `RELAY_PREFIXES` (`playingnow.js` reads `RELAY_ROOMS` too, so it counts players in relay rooms), and test with two browser windows in the same room.
149
150
- `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), Sky Duel and Putterby. 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.
0 commit comments