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