update: 2026-03-28 20:59
This commit is contained in:
@@ -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) {
|
||||
|
||||
Reference in New Issue
Block a user