diff --git a/index.html b/index.html index af7ac27..7205f31 100644 --- a/index.html +++ b/index.html @@ -114,6 +114,19 @@ #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); } + #msg .stats { display: flex; flex-direction: column; align-items: center; gap: 5px; margin-top: 2px; } + #msg .strow { display: flex; flex-wrap: wrap; justify-content: center; align-items: center; gap: 5px; max-width: 80%; } + #msg .strow .lbl { font-size: calc(10px * var(--s)); color: #fff; opacity: .75; letter-spacing: .08em; text-transform: uppercase; } + #msg .stk { + display: inline-flex; align-items: center; gap: 5px; padding: 2px 7px; + font-size: calc(10.5px * var(--s)); color: var(--muted); + border: 1px solid var(--border-2); border-radius: 7px; background: rgba(255,255,255,.04); + } + #msg .stk b { color: #fff; font-weight: 500; font-variant-numeric: tabular-nums; } + #msg .stk i { + width: 13px; height: 13px; border-radius: 4px; font-style: normal; + font-size: 9px; line-height: 13px; text-align: center; color: #fff; + } #dims { font-variant-numeric: tabular-nums; color: var(--dim); } #foot { display: flex; align-items: center; gap: 8px; margin-top: 10px; font-size: calc(11.5px * var(--s)); color: var(--muted); flex-wrap: nowrap; } @@ -284,6 +297,8 @@ 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 stats = { blk: {}, down: 0, pu: {} }; + function resetStats() { stats = { blk: {}, down: 0, pu: {} }; } var sound = true, ac = null, fxSig = ''; var scores = []; @@ -300,6 +315,21 @@ if (!scores.length) return 'Noch keine Ergebnisse'; return scores.map(function (v, i) { return (i + 1) + '. ' + v.toLocaleString('de-DE') + ccMark(v); }).join(' · '); } + function statsHtml() { + var hps = Object.keys(stats.blk).map(Number).sort(function (a, b) { return a - b; }); + var chips = hps.map(function (k) { return '' + k + '×-Block ' + stats.blk[k] + ''; }); + chips.push('Blöcke zerstört ' + stats.down + ''); + var pc = []; + PU.forEach(function (p) { + if (!stats.pu[p.id]) return; + pc.push('' + p.icon + '' + + p.name + ' ' + stats.pu[p.id] + ''); + }); + if (!pc.length) pc.push('keine Power-ups'); + return '
' + + '
Blöcke' + chips.join('') + '
' + + '
Power-ups' + pc.join('') + '
'; + } var opts = { round: true, autoFire: true, pu: true }; try { @@ -566,8 +596,8 @@ state = 'ready'; showMsg('Level ' + level, lives > 0 ? 'Klicken zum Starten' : 'Klicken für Neustart'); } - function showMsg(t, s) { - msg.innerHTML = '
' + t + '
' + s + '
'; + function showMsg(t, s, extra) { + msg.innerHTML = '
' + t + '
' + s + '
' + (extra || ''); msg.classList.remove('hidden'); } function hideMsg() { msg.classList.add('hidden'); } @@ -585,6 +615,7 @@ function newGame() { score = 0; level = 1; lives = START_LIVES; particles = []; continues = MAX_CONTINUES; checkpoint = 1; continueT = 0; ccUsed = 0; + resetStats(); for (var k in fx) fx[k] = 0; applyPaddle(); buildLevel(); resetBall(); hud(); hudFx(true); @@ -608,6 +639,7 @@ } function grab(p, x, y) { + stats.pu[p.id] = (stats.pu[p.id] || 0) + 1; if (p.id === 'multi') { var src = balls[0]; for (var i = 0; i < 2; i++) { @@ -673,7 +705,9 @@ /* ---------------- scoring ---------------- */ function hitBrick(b) { b.hp--; b.flash = 1; + stats.blk[b.max] = (stats.blk[b.max] || 0) + 1; if (b.hp <= 0) { + stats.down++; burst(b, b.c2); shake = Math.min(9, shake + 4); beep(210 + Math.min(combo, 12) * 42 + b.max * 18, 0.09, 'square', 0.05); dropPowerup(b.x + b.w / 2, b.y + b.h / 2); @@ -899,7 +933,7 @@ } catch (e) {} hud(); showMsg('Game Over', 'Erreicht: ' + score.toLocaleString('de-DE') + ' Punkte' + (ccUsed ? ' · ' + ccUsed + ' Continue genutzt' : '') + - '
Top 5: ' + top5Html() + '
Klick für neues Spiel'); + '
Top 5: ' + top5Html(), statsHtml() + '
Klick für neues Spiel
'); hudFx(true); }