Skip to content

Instantly share code, notes, and snippets.

@melcor76
Created November 19, 2019 13:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save melcor76/9a32c91b7fdb6a0cb7b3dbb711046193 to your computer and use it in GitHub Desktop.
Save melcor76/9a32c91b7fdb6a0cb7b3dbb711046193 to your computer and use it in GitHub Desktop.
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