diff --git a/README.md b/README.md
index 568aa04..a429548 100644
--- a/README.md
+++ b/README.md
@@ -17,6 +17,15 @@ Komplettes Breakout in einer einzigen HTML-Datei — ohne Build, ohne Abhängigk
| ← → | Paddle per Tastatur |
| `P` | Pause |
| `R` | Neustart |
+| `Optionen`-Button | Optionsmenü öffnen (pausiert das Spiel) |
+
+## Optionen
+
+Umschaltbar, Persistenz via `localStorage` (`breakout.options`):
+
+- **Rundes Paddle** — an: Abprall an der Bogen-Normalen; aus: klassischer fester Positionswinkel
+- **Auto-Feuer (Laser)** — an: Laser feuert alle 0,34 s automatisch; aus: eine Salve pro Klick/Leertaste
+- **Power-ups** — aus: keine Drops mehr, aktive Effekte werden beendet
## Power-ups
diff --git a/index.html b/index.html
index d090776..bf980dc 100644
--- a/index.html
+++ b/index.html
@@ -97,6 +97,18 @@
background: rgba(7,11,22,.62); pointer-events: none; transition: opacity .25s ease;
}
#msg.hidden { opacity: 0; }
+ #opts {
+ position: absolute; inset: 0; z-index: 5; display: flex; flex-direction: column;
+ align-items: center; justify-content: center; gap: 8px; cursor: default;
+ background: rgba(7,11,22,.9);
+ }
+ #opts.hidden { display: none; }
+ #opts .ttl { font-size: calc(20px * var(--s)); font-weight: 500; color: #fff; margin-bottom: 4px; }
+ #opts button.opt {
+ width: min(340px, 84%); display: flex; justify-content: space-between; align-items: center;
+ }
+ #opts button.opt b { color: var(--green); }
+ #opts button.opt.off b { color: var(--muted); }
#msg .big { font-size: calc(27px * var(--s)); font-weight: 500; color: #fff; letter-spacing: .02em; }
#msg .small { font-size: calc(12px * var(--s)); color: #a9b6cf; max-width: 72%; line-height: 1.5; }
#msg .accent { color: var(--green); }
@@ -161,11 +173,19 @@
Breakout
Klick ins Spielfeld zum Starten. Zerstörte Steine lassen gelegentlich Power-ups fallen — goldene, grüne und helle einsammeln, rote meiden.
+
+
Optionen
+
+
+
+
+
';
});
document.getElementById('pu-legend').innerHTML = html;
}
@@ -456,6 +495,7 @@
/* ---------------- power-up logic ---------------- */
function dropPowerup(bx, by) {
+ if (!opts.pu) return;
if (Math.random() > 0.24) return;
var total = 0; PU.forEach(function (p) { total += p.w; });
var roll = Math.random() * total, acc = 0, pick = PU[0];
@@ -517,6 +557,14 @@
return f;
}
+ function fireVolley() {
+ if (fx.laser <= 0) return false;
+ bullets.push({ x: paddle.x + 7, y: PY - 2 });
+ bullets.push({ x: paddle.x + paddle.w - 7, y: PY - 2 });
+ beep(1100, 0.05, 'square', 0.035);
+ return true;
+ }
+
function burst(b, color) {
for (var i = 0; i < 16; i++) {
var a = Math.random() * Math.PI * 2, s = 40 + Math.random() * 210;
@@ -578,17 +626,24 @@
beep(200, 0.05, 'sine', 0.05);
return true;
}
- /* Gebogenes Paddle: Reflexion an der Normalen des Paddel-Bogens */
- var tilt = off * ARC;
- var nx = Math.sin(tilt), ny = -Math.cos(tilt);
- var dot = b.vx * nx + b.vy * ny;
b.speed = Math.max(baseSpeed(), Math.min(b.speed + 6, baseSpeed() + 190));
- if (dot < 0) { b.vx -= 2 * dot * nx; b.vy -= 2 * dot * ny; }
- if (b.vy > 0) b.vy = -b.vy;
- if (Math.abs(b.vy) < b.speed * 0.26) b.vy = -b.speed * 0.26;
- var m = Math.sqrt(b.vx * b.vx + b.vy * b.vy) || 1;
- b.vx *= b.speed / m; b.vy *= b.speed / m;
- b.vx += paddle.vx * 0.22;
+ if (opts.round) {
+ /* Gebogenes Paddle: Reflexion an der Normalen des Paddel-Bogens */
+ var tilt = off * ARC;
+ var nx = Math.sin(tilt), ny = -Math.cos(tilt);
+ var dot = b.vx * nx + b.vy * ny;
+ if (dot < 0) { b.vx -= 2 * dot * nx; b.vy -= 2 * dot * ny; }
+ if (b.vy > 0) b.vy = -b.vy;
+ if (Math.abs(b.vy) < b.speed * 0.26) b.vy = -b.speed * 0.26;
+ var m = Math.sqrt(b.vx * b.vx + b.vy * b.vy) || 1;
+ b.vx *= b.speed / m; b.vy *= b.speed / m;
+ b.vx += paddle.vx * 0.22;
+ } else {
+ /* Lineares Paddle: klassischer fester Positionswinkel */
+ var ang = off * 1.02;
+ b.vx = Math.sin(ang) * b.speed + paddle.vx * 0.22;
+ b.vy = -Math.cos(ang) * b.speed;
+ }
b.y = PY - b.r - 0.6;
combo = 0; comboT = 0; hud();
beep(140, 0.05, 'sine', 0.05);
@@ -636,14 +691,9 @@
}
if (balls.length === 0) { loseLife(); return; }
- if (fx.laser > 0) {
+ if (fx.laser > 0 && opts.autoFire) {
laserCd -= dt;
- if (laserCd <= 0) {
- laserCd = 0.34;
- bullets.push({ x: paddle.x + 7, y: PY - 2 });
- bullets.push({ x: paddle.x + paddle.w - 7, y: PY - 2 });
- beep(1100, 0.05, 'square', 0.035);
- }
+ if (laserCd <= 0) { laserCd = 0.34; fireVolley(); }
}
for (var j = bullets.length - 1; j >= 0; j--) {
var bu = bullets[j]; bu.y -= 520 * dt;
@@ -827,20 +877,28 @@
if (fx.shrink > 0) { g.addColorStop(0, '#A32D2D'); g.addColorStop(1, '#F09595'); }
else if (fx.expand > 0) { g.addColorStop(0, '#1D9E75'); g.addColorStop(0.5, '#5DCAA5'); g.addColorStop(1, '#97C459'); }
else { g.addColorStop(0, '#378ADD'); g.addColorStop(0.5, '#AFA9EC'); g.addColorStop(1, '#1D9E75'); }
- ctx.beginPath();
- ctx.moveTo(paddle.x, PY + PH);
- ctx.lineTo(paddle.x, PY);
- ctx.quadraticCurveTo(paddle.x + paddle.w / 2, PY - 2 * ARC_V, paddle.x + paddle.w, PY);
- ctx.lineTo(paddle.x + paddle.w, PY + PH);
- ctx.closePath();
- ctx.fillStyle = g; ctx.fill();
- ctx.restore();
+ if (opts.round) {
+ ctx.beginPath();
+ ctx.moveTo(paddle.x, PY + PH);
+ ctx.lineTo(paddle.x, PY);
+ ctx.quadraticCurveTo(paddle.x + paddle.w / 2, PY - 2 * ARC_V, paddle.x + paddle.w, PY);
+ ctx.lineTo(paddle.x + paddle.w, PY + PH);
+ ctx.closePath();
+ ctx.fillStyle = g; ctx.fill();
+ ctx.restore();
- ctx.strokeStyle = 'rgba(255,255,255,0.5)'; ctx.lineWidth = 2.5;
- ctx.beginPath();
- ctx.moveTo(paddle.x + 8, PY + 1);
- ctx.quadraticCurveTo(paddle.x + paddle.w / 2, PY - 2 * ARC_V + 5, paddle.x + paddle.w - 8, PY + 1);
- ctx.stroke();
+ ctx.strokeStyle = 'rgba(255,255,255,0.5)'; ctx.lineWidth = 2.5;
+ ctx.beginPath();
+ ctx.moveTo(paddle.x + 8, PY + 1);
+ ctx.quadraticCurveTo(paddle.x + paddle.w / 2, PY - 2 * ARC_V + 5, paddle.x + paddle.w - 8, PY + 1);
+ ctx.stroke();
+ } else {
+ rr(paddle.x, PY, paddle.w, PH, 7); ctx.fillStyle = g; ctx.fill();
+ ctx.restore();
+
+ ctx.fillStyle = 'rgba(255,255,255,0.55)';
+ rr(paddle.x + 6, PY + 3, paddle.w - 12, 2.5, 1.5); ctx.fill();
+ }
if (fx.laser > 0) {
ctx.save(); ctx.shadowColor = '#EF9F27'; ctx.shadowBlur = 12; ctx.fillStyle = '#FAEEDA';
@@ -852,8 +910,9 @@
ctx.fillStyle = 'rgba(237,147,177,0.85)';
for (var i = 0; i < 5; i++) {
var t = (10 + i * (paddle.w - 20) / 4 - paddle.x) / paddle.w;
+ var dy = opts.round ? 4 * ARC_V * t * (1 - t) : 0;
ctx.beginPath();
- ctx.arc(paddle.x + 10 + i * (paddle.w - 20) / 4, PY - 4 * ARC_V * t * (1 - t), 2.2, 0, Math.PI * 2);
+ ctx.arc(paddle.x + 10 + i * (paddle.w - 20) / 4, PY - dy, 2.2, 0, Math.PI * 2);
ctx.fill();
}
}
@@ -988,19 +1047,20 @@
if (e.pointerType !== 'mouse' && wrap.setPointerCapture) { try { wrap.setPointerCapture(e.pointerId); } catch (err) {} }
if (e.pointerType === 'mouse' && !pointerLocked) canvasRequestLock();
if (state === 'levelclear') return;
- if (state === 'playing') { launchAttached(); 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') { canvasExitLock(); return; }
+ if (e.key === 'Escape') { if (optionsOpen) closeOptions(); canvasExitLock(); return; }
+ if (optionsOpen) return;
if (e.key === 'ArrowLeft') keys.left = true;
if (e.key === 'ArrowRight') keys.right = true;
if (e.code === 'Space' || e.key === 'Enter') {
e.preventDefault();
if (state === 'levelclear') return;
if (state === 'paused') { state = 'playing'; hideMsg(); last = performance.now(); return; }
- if (state === 'playing') { launchAttached(); return; }
+ if (state === 'playing') { launchAttached(); fireVolley(); return; }
startOrRestart();
}
if (e.key === 'p' || e.key === 'P') {
@@ -1015,6 +1075,38 @@
});
btnRestart.addEventListener('click', function () { newGame(); });
btnSound.addEventListener('click', function () { sound = !sound; btnSound.textContent = sound ? 'Ton an' : 'Ton aus'; });
+
+ function paintOpt(btn, on) {
+ var b = btn.querySelector('b');
+ if (b) b.textContent = on ? 'AN' : 'OFF';
+ btn.classList.toggle('off', !on);
+ }
+ function renderOpts() {
+ paintOpt(optRound, opts.round); paintOpt(optAuto, opts.autoFire); paintOpt(optPU, opts.pu);
+ if (laserHint) laserHint.textContent = opts.autoFire ? 'Laser feuert automatisch' : 'Laser: Salve per Klick/Leertaste';
+ }
+ function openOptions() {
+ optionsOpen = true;
+ canvasExitLock();
+ if (state === 'playing') state = 'paused';
+ hideMsg();
+ optsPanel.classList.remove('hidden');
+ }
+ function closeOptions() {
+ optionsOpen = false;
+ optsPanel.classList.add('hidden');
+ if (state === 'paused') showMsg('Pause', 'Klick oder P zum weiterspielen');
+ else if (state === 'ready' && lives > 0) showMsg('Level ' + level, 'Klicken zum Starten');
+ }
+ optRound.addEventListener('click', function () { opts.round = !opts.round; saveOpts(); renderOpts(); });
+ optAuto.addEventListener('click', function () { opts.autoFire = !opts.autoFire; laserCd = 0; saveOpts(); renderOpts(); legend(); });
+ optPU.addEventListener('click', function () {
+ opts.pu = !opts.pu; saveOpts(); renderOpts();
+ if (!opts.pu) { powerups.length = 0; for (var k in fx) fx[k] = 0; applyPaddle(); hudFx(true); }
+ });
+ optClose.addEventListener('click', closeOptions);
+ btnOptions.addEventListener('click', function () { if (optionsOpen) closeOptions(); else openOptions(); });
+ optsPanel.addEventListener('pointerdown', function (e) { e.stopPropagation(); });
window.addEventListener('resize', requestLayout);
window.addEventListener('orientationchange', requestLayout);
if (window.visualViewport) window.visualViewport.addEventListener('resize', requestLayout);
@@ -1060,7 +1152,7 @@
requestAnimationFrame(frame);
}
- legend(); layout(); buildLevel(); resetBall(); hud(); hudFx(true);
+ legend(); renderOpts(); layout(); buildLevel(); resetBall(); hud(); hudFx(true);
/* Layout finalisieren nachdem Fonts/Box-Messung stabil sind */
if (document.fonts && document.fonts.ready) document.fonts.ready.then(requestLayout);
setTimeout(requestLayout, 80);