From ada9ce73faa6f179f5b4ef5fca2d48789e05ab88 Mon Sep 17 00:00:00 2001 From: Josue Zamudio Date: Sat, 21 Mar 2026 03:05:35 +0000 Subject: [PATCH] Fix elimination check to only eliminate when piece blocks are above visible area Previously, players were eliminated when currentPiece.y <= 0, which was too aggressive. Pieces like I, T, S, Z, J, L spawn at y=0 but have empty top rows, so their actual blocks are at y >= 1 and visible on the board. Now we check if any part of the locked piece is actually above y=0 (not visible) before eliminating the player. --- public/js/game.js | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/public/js/game.js b/public/js/game.js index 6683d9e..0eff152 100644 --- a/public/js/game.js +++ b/public/js/game.js @@ -226,7 +226,21 @@ class TetrisGame { } // Check for game over (piece locked above visible area) - if (this.currentPiece.y <= 0) { + // Only eliminate if any part of the piece is above y=0 (not visible) + let pieceAboveBoard = false; + for (let row = 0; row < this.currentPiece.shape.length; row++) { + for (let col = 0; col < this.currentPiece.shape[row].length; col++) { + if (this.currentPiece.shape[row][col]) { + const boardY = this.currentPiece.y + row; + if (boardY < 0) { + pieceAboveBoard = true; + break; + } + } + } + if (pieceAboveBoard) break; + } + if (pieceAboveBoard) { this.gameOver = true; this.eliminated = true; }