-
-
Save melcor76/9a32c91b7fdb6a0cb7b3dbb711046193 to your computer and use it in GitHub Desktop.
js-tetris - count lines
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
clearLines() { | |
let lines = 0; | |
this.board.forEach((row, y) => { | |
if (row.every(value => value !== 0)) { | |
lines++; // Increase for cleared line | |
this.board.splice(y, 1); | |
this.board.unshift(Array(COLS).fill(0)); | |
} | |
}); | |
if (lines > 0) { | |
// Add points if we cleared some lines | |
account.score += this.getLineClearPoints(lines); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment