// --- TETRIS T PIECE (spawn orientation) ---
// Using 1 for blocks, 0 for empty
let currentPiece = [
[0, 1, 0],
[1, 1, 1],
[0, 0, 0],
];
// --- ROTATE FUNCTION (your version) ---
function rotate() {
const rotated = currentPiece[0].map((_, i) =>
currentPiece.map((row) => row[i]).reverse(),
);
currentPiece = rotated;
}
// --- HELPER TO PRINT MATRIX ---
function printMatrix(matrix) {
console.log(matrix.map((row) => row.join(" ")).join("\n"));
}
// --- TEST BEFORE ROTATION ---
console.log("Before rotation:");
printMatrix(currentPiece);
// --- APPLY ROTATION ---
rotate();
// --- TEST AFTER ROTATION ---
console.log("\nAfter rotation 1:");
printMatrix(currentPiece);
// --- APPLY ROTATION ---
rotate();
// --- TEST AFTER ROTATION ---
console.log("\nAfter rotation 2:");
printMatrix(currentPiece);
// --- APPLY ROTATION ---
rotate();
// --- TEST AFTER ROTATION ---
console.log("\nAfter rotation 3:");
printMatrix(currentPiece);
// --- APPLY ROTATION ---
rotate();
// --- TEST AFTER ROTATION ---
console.log("\nAfter rotation:");
printMatrix(currentPiece);