Skip to content

Instantly share code, notes, and snippets.

@melcor76
Created November 19, 2019 13:06
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/9da79744ebd244c52bc5c341b93c8a9e to your computer and use it in GitHub Desktop.
Save melcor76/9da79744ebd244c52bc5c341b93c8a9e to your computer and use it in GitHub Desktop.
js-tetris - clear lines
this.grid.forEach((row, y) => {
// If every value is greater than 0.
if (row.every(value => value > 0)) {
// Remove the row.
this.grid.splice(y, 1);
// Add zero filled row at the top.
this.grid.unshift(Array(COLS).fill(0));
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment