/board.js Secret
Created
November 19, 2019 12:54
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