Debug-Schalter: Level-Wahl im Optionsmenü (gespeichert) mit Fußzeile -/Feld/+ und Leveltyp, Tasten [ und ], Sprung auf Checkpoints; Start direkt per URL ?level=N, ?variant=pyramid|upside|fort|split oder ?debug=1
This commit is contained in:
1 parent
ce40671edc
commit
f985ae515a
1 file changed
+73
-2
+73
-2
@@ -132,6 +132,15 @@
|
|||||||
#foot { display: flex; align-items: center; gap: 8px; margin-top: 10px; font-size: calc(11.5px * var(--s)); color: var(--muted); flex-wrap: nowrap; }
|
#foot { display: flex; align-items: center; gap: 8px; margin-top: 10px; font-size: calc(11.5px * var(--s)); color: var(--muted); flex-wrap: nowrap; }
|
||||||
#foot .info { flex: 1 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
|
#foot .info { flex: 1 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
|
||||||
#actions { margin-left: auto; display: flex; gap: 8px; flex: none; white-space: nowrap; }
|
#actions { margin-left: auto; display: flex; gap: 8px; flex: none; white-space: nowrap; }
|
||||||
|
#dbg { display: flex; align-items: center; gap: 6px; flex: none; white-space: nowrap; }
|
||||||
|
#dbg.hidden { display: none; }
|
||||||
|
#dbg input {
|
||||||
|
width: 56px; font-family: var(--font); font-size: calc(11.5px * var(--s)); color: var(--text);
|
||||||
|
background: var(--chip); border: 1px solid var(--border-2); border-radius: 8px;
|
||||||
|
padding: calc(5px * var(--s)) calc(8px * var(--s));
|
||||||
|
}
|
||||||
|
#dbg input:focus { outline: none; border-color: var(--green); }
|
||||||
|
#dbg .var { font-size: calc(11px * var(--s)); color: var(--green); }
|
||||||
button {
|
button {
|
||||||
font-family: var(--font); font-size: calc(11.5px * var(--s)); color: var(--text);
|
font-family: var(--font); font-size: calc(11.5px * var(--s)); color: var(--text);
|
||||||
background: var(--chip); border: 1px solid var(--border-2);
|
background: var(--chip); border: 1px solid var(--border-2);
|
||||||
@@ -213,6 +222,7 @@
|
|||||||
<button class="opt" id="optRound"><span>Rundes Paddle</span><b>AN</b></button>
|
<button class="opt" id="optRound"><span>Rundes Paddle</span><b>AN</b></button>
|
||||||
<button class="opt" id="optAuto"><span>Auto-Feuer (Laser)</span><b>AN</b></button>
|
<button class="opt" id="optAuto"><span>Auto-Feuer (Laser)</span><b>AN</b></button>
|
||||||
<button class="opt" id="optPU"><span>Power-ups</span><b>AN</b></button>
|
<button class="opt" id="optPU"><span>Power-ups</span><b>AN</b></button>
|
||||||
|
<button class="opt" id="optDebug"><span>Debug: Level-Wahl</span><b>OFF</b></button>
|
||||||
<button id="optClose">Schließen</button>
|
<button id="optClose">Schließen</button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@@ -228,6 +238,12 @@
|
|||||||
|
|
||||||
<div id="foot">
|
<div id="foot">
|
||||||
<span class="info">Pfeiltasten links/rechts gehen auch · beim Power-up „Freies Paddle“ auch hoch/runter · <span id="laserhint">Laser feuert automatisch</span> · <span id="dims"></span></span>
|
<span class="info">Pfeiltasten links/rechts gehen auch · beim Power-up „Freies Paddle“ auch hoch/runter · <span id="laserhint">Laser feuert automatisch</span> · <span id="dims"></span></span>
|
||||||
|
<div id="dbg" class="hidden" title="Level wählen: Eingabe, - und + oder Tasten [ und ]">
|
||||||
|
<button id="dbgDown" title="Vorheriges Level">-</button>
|
||||||
|
<input id="dbgLvl" type="number" min="1" max="99" step="1" value="1">
|
||||||
|
<button id="dbgUp" title="Nächstes Level">+</button>
|
||||||
|
<span id="dbgVar" class="var">normal</span>
|
||||||
|
</div>
|
||||||
<div id="actions">
|
<div id="actions">
|
||||||
<button id="options">Optionen</button>
|
<button id="options">Optionen</button>
|
||||||
<button id="sound">Ton an</button>
|
<button id="sound">Ton an</button>
|
||||||
@@ -263,7 +279,13 @@
|
|||||||
var optRound = document.getElementById('optRound');
|
var optRound = document.getElementById('optRound');
|
||||||
var optAuto = document.getElementById('optAuto');
|
var optAuto = document.getElementById('optAuto');
|
||||||
var optPU = document.getElementById('optPU');
|
var optPU = document.getElementById('optPU');
|
||||||
|
var optDebug = document.getElementById('optDebug');
|
||||||
var optClose = document.getElementById('optClose');
|
var optClose = document.getElementById('optClose');
|
||||||
|
var dbgBox = document.getElementById('dbg');
|
||||||
|
var dbgLvl = document.getElementById('dbgLvl');
|
||||||
|
var dbgUp = document.getElementById('dbgUp');
|
||||||
|
var dbgDown = document.getElementById('dbgDown');
|
||||||
|
var dbgVar = document.getElementById('dbgVar');
|
||||||
var laserHint = document.getElementById('laserhint');
|
var laserHint = document.getElementById('laserhint');
|
||||||
var optionsOpen = false;
|
var optionsOpen = false;
|
||||||
|
|
||||||
@@ -366,13 +388,14 @@
|
|||||||
'<div class="strow"><span class="lbl">Power-ups</span>' + pc.join('') + '</div></div>';
|
'<div class="strow"><span class="lbl">Power-ups</span>' + pc.join('') + '</div></div>';
|
||||||
}
|
}
|
||||||
|
|
||||||
var opts = { round: true, autoFire: true, pu: true };
|
var opts = { round: true, autoFire: true, pu: true, debug: false };
|
||||||
try {
|
try {
|
||||||
var ov = JSON.parse(localStorage.getItem('breakout.options') || 'null');
|
var ov = JSON.parse(localStorage.getItem('breakout.options') || 'null');
|
||||||
if (ov && typeof ov === 'object') {
|
if (ov && typeof ov === 'object') {
|
||||||
opts.round = ov.round !== false;
|
opts.round = ov.round !== false;
|
||||||
opts.autoFire = ov.autoFire !== false;
|
opts.autoFire = ov.autoFire !== false;
|
||||||
opts.pu = ov.pu !== false;
|
opts.pu = ov.pu !== false;
|
||||||
|
opts.debug = ov.debug === true;
|
||||||
}
|
}
|
||||||
} catch (e) {}
|
} catch (e) {}
|
||||||
function saveOpts() { try { localStorage.setItem('breakout.options', JSON.stringify(opts)); } catch (e) {} }
|
function saveOpts() { try { localStorage.setItem('breakout.options', JSON.stringify(opts)); } catch (e) {} }
|
||||||
@@ -1346,6 +1369,7 @@
|
|||||||
var h = '';
|
var h = '';
|
||||||
for (var i = 0; i < Math.max(3, lives); i++) h += '<i class="' + (i < lives ? '' : 'off') + '"></i>';
|
for (var i = 0; i < Math.max(3, lives); i++) h += '<i class="' + (i < lives ? '' : 'off') + '"></i>';
|
||||||
elHearts.innerHTML = h;
|
elHearts.innerHTML = h;
|
||||||
|
if (opts.debug) dbgSync();
|
||||||
}
|
}
|
||||||
|
|
||||||
var fxChips = {};
|
var fxChips = {};
|
||||||
@@ -1473,6 +1497,7 @@
|
|||||||
window.addEventListener('keydown', function (e) {
|
window.addEventListener('keydown', function (e) {
|
||||||
if (e.key === 'Escape') { if (optionsOpen) closeOptions(); if (state === 'continue') gameOver(); canvasExitLock(); return; }
|
if (e.key === 'Escape') { if (optionsOpen) closeOptions(); if (state === 'continue') gameOver(); canvasExitLock(); return; }
|
||||||
if (optionsOpen) return;
|
if (optionsOpen) return;
|
||||||
|
if (opts.debug && (e.key === '[' || e.key === ']')) { debugStep(e.key === ']' ? 1 : -1); e.preventDefault(); return; }
|
||||||
if (e.key === 'ArrowLeft') { keys.left = true; e.preventDefault(); }
|
if (e.key === 'ArrowLeft') { keys.left = true; e.preventDefault(); }
|
||||||
if (e.key === 'ArrowRight') { keys.right = true; e.preventDefault(); }
|
if (e.key === 'ArrowRight') { keys.right = true; e.preventDefault(); }
|
||||||
if (e.key === 'ArrowUp') { keys.up = true; e.preventDefault(); }
|
if (e.key === 'ArrowUp') { keys.up = true; e.preventDefault(); }
|
||||||
@@ -1506,8 +1531,29 @@
|
|||||||
if (b) b.textContent = on ? 'AN' : 'OFF';
|
if (b) b.textContent = on ? 'AN' : 'OFF';
|
||||||
btn.classList.toggle('off', !on);
|
btn.classList.toggle('off', !on);
|
||||||
}
|
}
|
||||||
|
function dbgSync() {
|
||||||
|
if (!dbgBox) return;
|
||||||
|
dbgBox.classList.toggle('hidden', !opts.debug);
|
||||||
|
if (!opts.debug) return;
|
||||||
|
if (dbgLvl && document.activeElement !== dbgLvl) dbgLvl.value = level;
|
||||||
|
if (dbgVar) dbgVar.textContent = variant === 'normal' ? 'normal' : VTITLE[variant];
|
||||||
|
}
|
||||||
|
function setLevel(n) {
|
||||||
|
var target = clamp(Math.round(Number(n)) || 1, 1, 99);
|
||||||
|
level = target;
|
||||||
|
if (lives <= 0) { lives = START_LIVES; if (continues <= 0) continues = MAX_CONTINUES; }
|
||||||
|
hud(); buildLevel(); resetBall();
|
||||||
|
if (level % CHECKPOINT_EVERY === 0) {
|
||||||
|
checkpoint = level;
|
||||||
|
showMsg('Level ' + level + (variant === 'normal' ? '' : ' · ' + VTITLE[variant]) + ' · Checkpoint',
|
||||||
|
'Continue gesichert (' + continues + ') · Klick zum Starten');
|
||||||
|
}
|
||||||
|
hud(); dbgSync();
|
||||||
|
}
|
||||||
|
function debugStep(d) { if (opts.debug) setLevel(level + d); }
|
||||||
function renderOpts() {
|
function renderOpts() {
|
||||||
paintOpt(optRound, opts.round); paintOpt(optAuto, opts.autoFire); paintOpt(optPU, opts.pu);
|
paintOpt(optRound, opts.round); paintOpt(optAuto, opts.autoFire); paintOpt(optPU, opts.pu); paintOpt(optDebug, opts.debug);
|
||||||
|
dbgSync();
|
||||||
if (laserHint) laserHint.textContent = opts.autoFire ? 'Laser feuert automatisch' : 'Laser: Salve per Klick/Leertaste';
|
if (laserHint) laserHint.textContent = opts.autoFire ? 'Laser feuert automatisch' : 'Laser: Salve per Klick/Leertaste';
|
||||||
}
|
}
|
||||||
function openOptions() {
|
function openOptions() {
|
||||||
@@ -1529,6 +1575,14 @@
|
|||||||
opts.pu = !opts.pu; saveOpts(); renderOpts();
|
opts.pu = !opts.pu; saveOpts(); renderOpts();
|
||||||
if (!opts.pu) { powerups.length = 0; for (var k in fx) fx[k] = 0; applyPaddle(); hudFx(true); }
|
if (!opts.pu) { powerups.length = 0; for (var k in fx) fx[k] = 0; applyPaddle(); hudFx(true); }
|
||||||
});
|
});
|
||||||
|
optDebug.addEventListener('click', function () { opts.debug = !opts.debug; saveOpts(); renderOpts(); });
|
||||||
|
dbgUp.addEventListener('click', function () { debugStep(1); if (dbgLvl.blur) dbgLvl.blur(); });
|
||||||
|
dbgDown.addEventListener('click', function () { debugStep(-1); if (dbgLvl.blur) dbgLvl.blur(); });
|
||||||
|
dbgLvl.addEventListener('change', function () { setLevel(dbgLvl.value); });
|
||||||
|
dbgLvl.addEventListener('keydown', function (e) {
|
||||||
|
e.stopPropagation();
|
||||||
|
if (e.key === 'Enter') { setLevel(dbgLvl.value); if (dbgLvl.blur) dbgLvl.blur(); }
|
||||||
|
});
|
||||||
optClose.addEventListener('click', closeOptions);
|
optClose.addEventListener('click', closeOptions);
|
||||||
btnOptions.addEventListener('click', function () { if (optionsOpen) closeOptions(); else openOptions(); });
|
btnOptions.addEventListener('click', function () { if (optionsOpen) closeOptions(); else openOptions(); });
|
||||||
optsPanel.addEventListener('pointerdown', function (e) { e.stopPropagation(); });
|
optsPanel.addEventListener('pointerdown', function (e) { e.stopPropagation(); });
|
||||||
@@ -1597,7 +1651,24 @@
|
|||||||
requestAnimationFrame(frame);
|
requestAnimationFrame(frame);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Debug-Start: ?level=16 oder ?variant=split (pyramid|upside|fort|split), ?debug=1 schaltet die Wahl ein */
|
||||||
|
var startupLevel = 0;
|
||||||
|
try {
|
||||||
|
var pm = {};
|
||||||
|
((window.location && window.location.search) || '').replace(/^\?/, '').split('&').forEach(function (kv) {
|
||||||
|
if (!kv) return;
|
||||||
|
var p = kv.split('=');
|
||||||
|
pm[p[0]] = decodeURIComponent(p[1] || '');
|
||||||
|
});
|
||||||
|
if (pm.debug === '1' || pm.level || pm.variant) opts.debug = true;
|
||||||
|
if (pm.level) startupLevel = clamp(parseInt(pm.level, 10) || 1, 1, 99);
|
||||||
|
if (pm.variant) {
|
||||||
|
for (var li = 1; li <= 40; li++) { if (variantOf(li) === pm.variant) { startupLevel = li; break; } }
|
||||||
|
}
|
||||||
|
} catch (e) {}
|
||||||
|
|
||||||
legend(); renderOpts(); layout(); buildLevel(); resetBall(); hud(); hudFx(true);
|
legend(); renderOpts(); layout(); buildLevel(); resetBall(); hud(); hudFx(true);
|
||||||
|
if (startupLevel > 1) setLevel(startupLevel);
|
||||||
drawReady = true;
|
drawReady = true;
|
||||||
redraw();
|
redraw();
|
||||||
/* Layout finalisieren nachdem Fonts/Box-Messung stabil sind */
|
/* Layout finalisieren nachdem Fonts/Box-Messung stabil sind */
|
||||||
|
|||||||
Reference in new issue
Block a user