Skip to content

Instantly share code, notes, and snippets.

@melcor76
Created November 19, 2019 13:19
Embed
What would you like to do?
js-tetris - count lines
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