Update index.html to final version (cleanup, toolbar sync fixes)
This commit is contained in:
+3
-10
@@ -445,7 +445,6 @@
|
||||
if (shakeT <= 0) shakeMag = 0;
|
||||
}
|
||||
for (const br of bricks) if (br.flash > 0) br.flash = Math.max(0, br.flash - dt * 4);
|
||||
for (const b of balls) if (b.vx || b.vy) { /* trail handled below */ }
|
||||
|
||||
if (state.mode === 'levelclear') {
|
||||
state.timer -= dt;
|
||||
@@ -569,7 +568,6 @@
|
||||
}
|
||||
ctx.shadowBlur = 0;
|
||||
|
||||
// 加宽倒计时条
|
||||
if (wideTimer > 0) {
|
||||
ctx.textAlign = 'center';
|
||||
ctx.font = '700 13px ui-monospace, monospace';
|
||||
@@ -594,7 +592,6 @@
|
||||
ctx.fill();
|
||||
ctx.restore();
|
||||
|
||||
// 高光
|
||||
ctx.save();
|
||||
ctx.globalAlpha = 0.35;
|
||||
ctx.fillStyle = '#ffffff';
|
||||
@@ -602,7 +599,6 @@
|
||||
ctx.fill();
|
||||
ctx.restore();
|
||||
|
||||
// 受击闪白
|
||||
if (br.flash > 0) {
|
||||
ctx.save();
|
||||
ctx.globalAlpha = br.flash * 0.85;
|
||||
@@ -637,7 +633,6 @@
|
||||
|
||||
function drawBalls() {
|
||||
for (const b of balls) {
|
||||
// 拖尾
|
||||
for (let i = 0; i < b.trail.length; i++) {
|
||||
const t = b.trail[i];
|
||||
const k = (i + 1) / b.trail.length;
|
||||
@@ -663,7 +658,6 @@
|
||||
ctx.restore();
|
||||
}
|
||||
|
||||
// 瞄准虚线
|
||||
if (stuck && balls.length) {
|
||||
const b = balls[0];
|
||||
ctx.save();
|
||||
@@ -777,10 +771,12 @@
|
||||
} else if (state.mode === 'paused') {
|
||||
resume();
|
||||
}
|
||||
updateToolbar();
|
||||
}
|
||||
function resume() {
|
||||
state.mode = 'playing';
|
||||
hideOverlay();
|
||||
updateToolbar();
|
||||
}
|
||||
function updateToolbar() {
|
||||
document.getElementById('btnPause').textContent = state.mode === 'paused' ? '▶ 继续' : '⏸ 暂停';
|
||||
@@ -824,9 +820,7 @@
|
||||
}
|
||||
}
|
||||
if (k === 'p' || k === 'P' || k === 'Escape') togglePause();
|
||||
|
||||
if (k === 'm' || k === 'M') toggleSound();
|
||||
updateToolbar();
|
||||
});
|
||||
|
||||
window.addEventListener('keyup', (e) => { keys[e.key] = false; });
|
||||
@@ -842,12 +836,11 @@
|
||||
if (!muted) { initAudio(); if (audioCtx && audioCtx.state === 'suspended') audioCtx.resume(); }
|
||||
}
|
||||
document.getElementById('btnSound').addEventListener('click', toggleSound);
|
||||
document.getElementById('btnPause').addEventListener('click', () => { initAudio(); togglePause(); updateToolbar(); });
|
||||
document.getElementById('btnPause').addEventListener('click', () => { initAudio(); togglePause(); });
|
||||
document.getElementById('btnRestart').addEventListener('click', () => {
|
||||
initAudio();
|
||||
if (audioCtx && audioCtx.state === 'suspended') audioCtx.resume();
|
||||
startGame();
|
||||
updateToolbar();
|
||||
});
|
||||
|
||||
/* ======================= 初始化 ======================= */
|
||||
|
||||
Reference in New Issue
Block a user