update: 2026-03-28 20:59

This commit is contained in:
2026-03-28 20:59:52 +08:00
parent e21d58e603
commit 1c81d4e6ea
611 changed files with 27847 additions and 65061 deletions

View File

@@ -402,15 +402,28 @@ class TetrisGame {
gameOver() {
this.gameRunning = false;
this.gamePaused = false;
// 显示游戏统计
gameStats.showStats({
score: this.score,
level: this.level,
lines: this.lines,
playTime: Date.now() - this.gameStartTime,
maxCombo: this.maxCombo
});
const playMs = Date.now() - this.gameStartTime;
const sec = Math.floor(playMs / 1000);
const m = String(Math.floor(sec / 60)).padStart(2, '0');
const s = String(sec % 60).padStart(2, '0');
const summary = document.getElementById('endSummary');
if (summary) {
summary.innerHTML =
`<p>得分 <strong>${this.score}</strong> · 等级 <strong>${this.level}</strong></p>` +
`<p>消除 <strong>${this.lines}</strong> 行 · 用时 <strong>${m}:${s}</strong></p>`;
}
const statsEl = document.getElementById('gameStats');
if (statsEl) statsEl.style.display = 'flex';
const btn = document.getElementById('playAgainBtn');
if (btn) {
btn.onclick = () => {
statsEl.style.display = 'none';
if (window.game && typeof window.game.restart === 'function') window.game.restart();
};
}
}
gameLoop(currentTime = 0) {