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