From c0e1cb9f60596c0719e44cd8d8ea33f9227b0187 Mon Sep 17 00:00:00 2001 From: Zee Date: Tue, 20 Jan 2026 17:00:22 +0000 Subject: [PATCH 1/3] Added Faster drop (267-272) --- src/js/index.js | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/js/index.js b/src/js/index.js index 38fcf88..7033a32 100644 --- a/src/js/index.js +++ b/src/js/index.js @@ -1,4 +1,5 @@ -class Controller { + + class Controller { static #KEY_CODES = { ENTER: 13, SPACE: 32, @@ -263,8 +264,9 @@ class Game { moveTetrominoDown() { if (this.#isGameOver) return; - this.#currentTetromino.y += 1; - + while (!this.#hasCollision()) { + this.#currentTetromino.y += 1; + } if (this.#hasCollision()) { this.#currentTetromino.y -= 1; this.#lockTetromino(); From 2ecfce1563a03db71ed801fa3c3261d826568bad Mon Sep 17 00:00:00 2001 From: Zee Date: Tue, 20 Jan 2026 17:01:20 +0000 Subject: [PATCH 2/3] Lines --- src/js/index.js | 65 ++++++++++++++++++++++++++----------------------- 1 file changed, 34 insertions(+), 31 deletions(-) diff --git a/src/js/index.js b/src/js/index.js index 7033a32..a49a05f 100644 --- a/src/js/index.js +++ b/src/js/index.js @@ -1,5 +1,5 @@ - class Controller { +class Controller { static #KEY_CODES = { ENTER: 13, SPACE: 32, @@ -21,7 +21,7 @@ constructor(game, view) { this.#game = game; this.#view = view; - + this.#initializeEventListeners(); this.#view.renderStartScreen(); } @@ -91,7 +91,7 @@ #handleKeyDown(event) { const gameState = this.#game.getState(); - + switch (event.keyCode) { case Controller.#KEY_CODES.SPACE: case Controller.#KEY_CODES.ENTER: @@ -236,7 +236,7 @@ class Game { getState() { const displayBoard = this.#createDisplayBoard(); - + return { score: this.#score, level: this.level, @@ -264,9 +264,12 @@ class Game { moveTetrominoDown() { if (this.#isGameOver) return; - while (!this.#hasCollision()) { + let count = 0; + + while (!this.#hasCollision() && count < 5) { this.#currentTetromino.y += 1; - } + count += 1; + } if (this.#hasCollision()) { this.#currentTetromino.y -= 1; this.#lockTetromino(); @@ -298,7 +301,7 @@ class Game { #createDisplayBoard() { const displayBoard = []; - + for (let row = 0; row < this.#gameBoard.length; row++) { displayBoard[row] = [...this.#gameBoard[row]]; } @@ -330,26 +333,26 @@ class Game { #hasCollision() { const { y: tetrominoY, x: tetrominoX, blocks } = this.#currentTetromino; - + for (let row = 0; row < blocks.length; row++) { for (let col = 0; col < blocks[row].length; col++) { if (!blocks[row][col]) continue; - + const boardY = tetrominoY + row; const boardX = tetrominoX + col; - + if (boardY < 0) continue; - - const isOutOfBounds = - boardY >= Game.#BOARD_HEIGHT || - boardX < 0 || + + const isOutOfBounds = + boardY >= Game.#BOARD_HEIGHT || + boardX < 0 || boardX >= Game.#BOARD_WIDTH; - - const isOccupied = - boardY >= 0 && - this.#gameBoard[boardY] && + + const isOccupied = + boardY >= 0 && + this.#gameBoard[boardY] && this.#gameBoard[boardY][boardX]; - + if (isOutOfBounds || isOccupied) { return true; } @@ -361,7 +364,7 @@ class Game { #lockTetromino() { const { y: tetrominoY, x: tetrominoX, blocks } = this.#currentTetromino; - + for (let row = 0; row < blocks.length; row++) { for (let col = 0; col < blocks[row].length; col++) { if (blocks[row][col]) { @@ -431,14 +434,14 @@ class Game { class View { static #TETROMINO_COLORS = { - 1: "#00FFFF", - 2: "#5D2F77", - 3: "#00FF00", - 4: "#4682B4", - 5: "#8A2BE2", - 6: "#FECA57", - 7: "#FF6347", -}; + 1: "#00FFFF", + 2: "#5D2F77", + 3: "#00FF00", + 4: "#4682B4", + 5: "#8A2BE2", + 6: "#FECA57", + 7: "#FF6347", + }; static #FONT_FAMILY = "'Courier New'"; static #FONT_SIZE_LARGE = 18; @@ -488,7 +491,7 @@ class View { renderEndScreen({ score }) { this.#clearScreen(); - + const centerX = this.#width / 3; const centerY = this.#height / 2; const lineHeight = 48; @@ -497,7 +500,7 @@ class View { this.#context.font = `${View.#FONT_SIZE_LARGE}px ${View.#FONT_FAMILY}`; this.#context.textAlign = "center"; this.#context.textBaseline = "middle"; - + this.#context.fillText("GAME OVER", centerX, centerY - lineHeight); this.#context.fillText(`Score: ${score}`, centerX, centerY); this.#context.fillText("Press Enter to Restart", centerX, centerY + lineHeight); @@ -513,7 +516,7 @@ class View { #calculateDimensions(rows, columns) { const boardWidth = (this.#width * 2) / 3; const boardHeight = this.#height; - + this.#boardArea = { x: View.#BORDER_WIDTH, y: View.#BORDER_WIDTH, From acd423774cf3769bb43bf709357788ff36150ed3 Mon Sep 17 00:00:00 2001 From: Zee Date: Tue, 20 Jan 2026 17:14:46 +0000 Subject: [PATCH 3/3] Slight faster softdrop --- src/js/index.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/js/index.js b/src/js/index.js index a49a05f..26536b3 100644 --- a/src/js/index.js +++ b/src/js/index.js @@ -266,7 +266,7 @@ class Game { let count = 0; - while (!this.#hasCollision() && count < 5) { + while (!this.#hasCollision() && count < 3) { this.#currentTetromino.y += 1; count += 1; }