Fold the menu into the title screen, and stop the theme restarting

The menu stage was the same logo on the same backdrop with two buttons, so it
read as the title screen failing to advance. The buttons move onto the title
screen in place of the control list, which is the tutorial's job now.

Death no longer reloads the page. The reload was an honest full reset, but it
also tore down the AudioContext — so the theme restarted from silence every
time you died, when it should carry straight on from the death summary into the
title screen. restartRun() puts G, P, O, ball and score back from a
structuredClone taken at module load (all plain data, so the clone is the whole
job and a field added later is covered for free), and the two modules with
timers of their own reset themselves: every zombies array plus spawnT/moanT/
mgTick, and input's held keys and half-finished drags, which would otherwise be
inherited by the next run's first frame.

The overlay is hidden rather than removed so it can come straight back, which
needs its own [hidden] rule to beat the display:grid on #intro.

The theme starts on the first tap and never restarts: loopBed's beds.has guard
already makes every later menuMusic() a no-op.

Verified: one background-music fetch across launch -> run -> death -> title ->
second run, and a full second run through the transition after the in-place
reset.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
wuwiandClaude Opus 5 committed 2026-08-01 16:25:20 +02:00
1 parent 2d4fa79258
commit d3aabc4bd6
7 files changed
+114 -74

No files matched your search

+14
View File
@@ -103,6 +103,20 @@ export const G = {
logShow: false, // tap the scoreboard to toggle the on-screen miss-log dump
};
// A pristine deep copy of every mutable bag, taken at module load before anything can touch them.
// This is what replaced `location.reload()` on death: the reload was an honest full reset, but it
// also tore down the AudioContext, so the menu theme restarted from silence every time you died.
// Everything above is plain data — primitives, nulls, small arrays and {} — so a structured clone
// is the whole job.
const PRISTINE = structuredClone({ G, P, O, ball, score });
export function resetState() {
const p = structuredClone(PRISTINE);
Object.assign(G, p.G); Object.assign(P, p.P); Object.assign(O, p.O);
Object.assign(ball, p.ball); Object.assign(score, p.score);
G.hp = G.hpMax = TUNE.playerHp; // re-read: the T panel may have moved it since boot
crowd.cheer = 0;
}
export const other = s => s === 'P' ? 'O' : 'P';
export const deuceSide = () => (score.pts[0] + score.pts[1]) % 2 === 0; // even points → deuce (right) side