-
-
Save melcor76/0b8476b0aa8cfd92af4cfec1c46ef639 to your computer and use it in GitHub Desktop.
js-tetris - rotate
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
// Transpose matrix, p is the Piece. | |
for (let y = 0; y < p.shape.length; ++y) { | |
for (let x = 0; x < y; ++x) { | |
[p.shape[x][y], p.shape[y][x]] = | |
[p.shape[y][x], p.shape[x][y]]; | |
} | |
} | |
// Reverse the order of the columns. | |
p.shape.forEach(row => row.reverse()); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment