Split the monolith into ES modules; hoist scattered magic numbers
game.js (830 lines) -> 9 modules, native ES modules so still zero build step: dom canvas handles (imports nothing; keeps cycles harmless) config TUNE (live-tunable) + structural constants state all mutable game state (G) + setupPoint/sendBoy audio sfx synthesis, recorded umpire voice, reverb, speech fallback input keyboard + touch, exports axes and takeFlickAim() gameplay ballistics, swings, serve, rules, AI, update loop render camera, viewport, sprites, crowd, all drawing panel T tuning UI main boot, loop, intro, window.T test hooks Deduped into named constants: bounce tempo (was in 3 places), contact height band, intercept zone depth, home positions, player bounds, toss params, shot depths, pose hold time, sprite scale, actor heights. Also extracted drawShadow/drawBall/expirePose from repeated code. One intentional import cycle (input <-> gameplay), safe: both sides only call functions at runtime, never during module evaluation. Regression-verified in browser sims: point cycle, CPU returns 11/12, assist contract 8/8, corner-winner gradient intact (0/12 perfect corners returned, 10/12 center balls returned). Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
1 parent
f2bf21f252
commit
c506a631c2
12 files changed
+936
-824
No files matched your search
@@ -0,0 +1,18 @@
|
||||
// Live tuning panel (T key): number inputs for every TUNE value.
|
||||
|
||||
import { TUNE } from './config.js';
|
||||
|
||||
let panel = null;
|
||||
export function togglePanel() {
|
||||
if (panel) { panel.remove(); panel = null; return; }
|
||||
panel = document.createElement('div');
|
||||
panel.style.cssText = 'position:fixed;top:8px;right:8px;background:#141a26;color:#cdd6e4;font:11px monospace;padding:8px;border:1px solid #3a4a66;max-height:90vh;overflow:auto';
|
||||
for (const k of Object.keys(TUNE)) {
|
||||
const row = document.createElement('div');
|
||||
const v = TUNE[k];
|
||||
row.innerHTML = `<label>${k} <input type="number" step="${v < 2 ? 0.02 : 1}" value="${v}" style="width:60px;background:#0c1018;color:#fff;border:1px solid #333"></label>`;
|
||||
row.querySelector('input').oninput = e => TUNE[k] = parseFloat(e.target.value) || 0;
|
||||
panel.appendChild(row);
|
||||
}
|
||||
document.body.appendChild(panel);
|
||||
}
|
||||
Reference in new issue
Block a user