-
-
Save melcor76/9da79744ebd244c52bc5c341b93c8a9e to your computer and use it in GitHub Desktop.
js-tetris - clear 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
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