From d884d587e55e402a1be7b7a5e4bd396a74edcbe0 Mon Sep 17 00:00:00 2001 From: michael Date: Tue, 13 Oct 2026 17:21:44 +0000 Subject: [PATCH] Continue-System: Checkpoints alle 5 Level, 3 Continues, 10s-Countdown (Klick/C weiter, ESC aufgeben), Neustart im Checkpoint mit 3 Leben und Punkte bleiben; HUD-Pill 'Continues' und CC-Markierung im Highscore --- index.html | 89 +++++++++++++++++++++++++++++++++++++++++++++--------- 1 file changed, 74 insertions(+), 15 deletions(-) diff --git a/index.html b/index.html index 92c4261..2658f95 100644 --- a/index.html +++ b/index.html @@ -184,6 +184,7 @@ Bestwert 0 Level 1 Combo ×1,0 + Continues 3 Leben @@ -240,6 +241,7 @@ var elBest = document.querySelector('#best b'); var elLevel = document.querySelector('#level b'); var elCombo = document.querySelector('#combo b'); + var elCont = document.querySelector('#cont b'); var elHearts = document.getElementById('hearts'); var btnSound = document.getElementById('sound'); var btnRestart = document.getElementById('restart'); @@ -280,6 +282,8 @@ var laserCd = 0; var state = 'ready', score = 0, best = 0, level = 1, lives = 3; var combo = 0, comboT = 0, shake = 0, shakeX = 0, shakeY = 0, levelTimer = 0; + var CHECKPOINT_EVERY = 5, MAX_CONTINUES = 3, CONTINUE_TIME = 10, START_LIVES = 3; + var continues = MAX_CONTINUES, checkpoint = 1, continueT = 0, ccUsed = 0, contTick = 0; var sound = true, ac = null, fxSig = ''; var scores = []; @@ -289,9 +293,12 @@ scores.sort(function (a, b) { return b - a; }); scores = scores.slice(0, 5); best = scores[0] || 0; + var scoreCC = {}; + try { scoreCC = JSON.parse(localStorage.getItem('breakout.scoreCC') || '{}') || {}; } catch (e) { scoreCC = {}; } + function ccMark(v) { return scoreCC[String(v)] > 0 ? ' (' + scoreCC[String(v)] + ' CC)' : ''; } function top5Html() { if (!scores.length) return 'Noch keine Ergebnisse'; - return scores.map(function (v, i) { return (i + 1) + '. ' + v.toLocaleString('de-DE'); }).join(' · '); + return scores.map(function (v, i) { return (i + 1) + '. ' + v.toLocaleString('de-DE') + ccMark(v); }).join(' · '); } var opts = { round: true, autoFire: true, pu: true }; @@ -576,10 +583,11 @@ } function startOrRestart() { if (lives > 0) launchAll(); else newGame(); } function newGame() { - score = 0; level = 1; lives = 3; particles = []; + score = 0; level = 1; lives = START_LIVES; particles = []; + continues = MAX_CONTINUES; checkpoint = 1; continueT = 0; ccUsed = 0; for (var k in fx) fx[k] = 0; applyPaddle(); - buildLevel(); resetBall(); hud(); + buildLevel(); resetBall(); hud(); hudFx(true); } /* ---------------- power-up logic ---------------- */ @@ -834,20 +842,56 @@ beep(90, 0.35, 'sawtooth', 0.07); fx.shrink = 0; fx.fast = 0; applyPaddle(); if (lives <= 0) { - state = 'over'; - if (score > 0) { - scores.push(score); - scores.sort(function (a, b) { return b - a; }); - scores = scores.slice(0, 5); - best = scores[0]; + if (continues > 0) { + state = 'continue'; continueT = CONTINUE_TIME; contTick = 0; + hud(); showContinue(); hudFx(true); + beep(300, 0.3, 'triangle', 0.05); + return; } - try { localStorage.setItem('breakout.scores', JSON.stringify(scores)); } catch (e) {} - hud(); - showMsg('Game Over', 'Erreicht: ' + score.toLocaleString('de-DE') + ' Punkte
Top 5: ' + top5Html() + '
Klick für neues Spiel'); - hudFx(true); + gameOver(); } else resetBall(); } + function showContinue() { + showMsg('Continue? ' + Math.ceil(continueT), + 'Neustart auf Level ' + checkpoint + ' mit ' + START_LIVES + ' Leben, Punkte bleiben
Klick oder Taste C nutzen · ESC gibt auf · noch ' + continues + ' Continue'); + } + + function doContinue() { + if (state !== 'continue' || continues <= 0) return; + continues--; ccUsed++; + level = checkpoint; lives = START_LIVES; + for (var k in fx) fx[k] = 0; + applyPaddle(); + powerups.length = 0; bullets.length = 0; notes.length = 0; particles.length = 0; + combo = 0; comboT = 0; continueT = 0; + hud(); hudFx(true); buildLevel(); resetBall(); + beep(520, 0.12, 'triangle', 0.06); + setTimeout(function () { beep(780, 0.14, 'triangle', 0.06); }, 100); + } + + function gameOver() { + state = 'over'; continueT = 0; + if (score > 0) { + scores.push(score); + scores.sort(function (a, b) { return b - a; }); + scores = scores.slice(0, 5); + best = scores[0]; + if (ccUsed > 0) scoreCC[String(score)] = ccUsed; + } + var keep = {}; + scores.forEach(function (v) { if (scoreCC[String(v)] > 0) keep[String(v)] = scoreCC[String(v)]; }); + scoreCC = keep; + try { + localStorage.setItem('breakout.scores', JSON.stringify(scores)); + localStorage.setItem('breakout.scoreCC', JSON.stringify(scoreCC)); + } catch (e) {} + hud(); + showMsg('Game Over', 'Erreicht: ' + score.toLocaleString('de-DE') + ' Punkte' + (ccUsed ? ' · ' + ccUsed + ' Continue genutzt' : '') + + '
Top 5: ' + top5Html() + '
Klick für neues Spiel'); + hudFx(true); + } + /* ---------------- draw ---------------- */ function draw() { ctx.setTransform(sx, 0, 0, sx, 0, 0); @@ -1072,6 +1116,7 @@ elBest.textContent = best.toLocaleString('de-DE'); elLevel.textContent = level; elCombo.textContent = '×' + (1 + Math.min(combo, 8) * 0.5).toFixed(1).replace('.', ','); + elCont.textContent = continues; var h = ''; for (var i = 0; i < Math.max(3, lives); i++) h += ''; elHearts.innerHTML = h; @@ -1179,13 +1224,14 @@ wrap.addEventListener('pointerdown', function (e) { if (e.pointerType !== 'mouse' && wrap.setPointerCapture) { try { wrap.setPointerCapture(e.pointerId); } catch (err) {} } if (e.pointerType === 'mouse' && !pointerLocked) canvasRequestLock(); + if (state === 'continue') { doContinue(); return; } if (state === 'levelclear') return; if (state === 'playing') { launchAttached(); fireVolley(); return; } if (state === 'paused') { state = 'playing'; hideMsg(); last = performance.now(); return; } startOrRestart(); }); window.addEventListener('keydown', function (e) { - if (e.key === 'Escape') { if (optionsOpen) closeOptions(); canvasExitLock(); return; } + if (e.key === 'Escape') { if (optionsOpen) closeOptions(); if (state === 'continue') gameOver(); canvasExitLock(); return; } if (optionsOpen) return; if (e.key === 'ArrowLeft') { keys.left = true; e.preventDefault(); } if (e.key === 'ArrowRight') { keys.right = true; e.preventDefault(); } @@ -1193,11 +1239,13 @@ if (e.key === 'ArrowDown') { keys.down = true; e.preventDefault(); } if (e.code === 'Space' || e.key === 'Enter') { e.preventDefault(); - if (state === 'levelclear') return; + if (state === 'continue') { doContinue(); return; } + if (state === 'levelclear') return; if (state === 'paused') { state = 'playing'; hideMsg(); last = performance.now(); return; } if (state === 'playing') { launchAttached(); fireVolley(); return; } startOrRestart(); } + if (e.key === 'c' || e.key === 'C') { if (state === 'continue') doContinue(); return; } if (e.key === 'p' || e.key === 'P') { if (state === 'playing') { state = 'paused'; showMsg('Pause', 'Klick oder P zum weiterspielen'); } else if (state === 'paused') { state = 'playing'; hideMsg(); last = performance.now(); } @@ -1275,10 +1323,21 @@ powerups.length = 0; level++; if (lives < 5 && level % 2 === 0) lives++; + if (level % CHECKPOINT_EVERY === 0) checkpoint = level; hud(); buildLevel(); resetBall(); + if (checkpoint === level) { + showMsg('Level ' + level + ' · Checkpoint', 'Continue gesichert (' + continues + ') · Klick zum Starten'); + beep(720, 0.14, 'triangle', 0.06); + } } } + if (state === 'continue') { + continueT -= dt; contTick -= dt; + if (contTick <= 0) { contTick = 0.2; showContinue(); } + if (continueT <= 0) { continueT = 0; gameOver(); } + } + for (var i = 0; i < notes.length; i++) notes[i].t -= dt; for (var j = notes.length - 1; j >= 0; j--) if (notes[j].t <= 0) notes.splice(j, 1);