diff --git a/app/src/main/java/school_project/Piece.java b/app/src/main/java/school_project/Piece.java index f5dde6b..3a92feb 100644 --- a/app/src/main/java/school_project/Piece.java +++ b/app/src/main/java/school_project/Piece.java @@ -12,16 +12,15 @@ public class Piece extends Shape{ /** * Rotate the matrix of the piece. Used when the player right click - * TODO: ALGORITHME INCORECTE, A REFAIRE * * @param times Set the amount of time the rotation should be executed. Should be set between 1 and 3. */ public void RotateRight(int times){ while(times > 0) { boolean[][] temp_matrix = new boolean[width][height]; - for (int i = 0; i < height; i++) { - for (int j = 0; j < width; j++) { - temp_matrix[j][i] = matrix[i][j]; + for (int i = 0; i < width; i++) { + for (int j = 0; j < height; j++) { + temp_matrix[i][j] = matrix[-j+height-1][i]; } } times--; diff --git a/app/src/test/java/school_project/PieceTest.java b/app/src/test/java/school_project/PieceTest.java index ad9e23c..e3adc2e 100644 --- a/app/src/test/java/school_project/PieceTest.java +++ b/app/src/test/java/school_project/PieceTest.java @@ -16,7 +16,7 @@ class PieceTest { boolean[][] piece1_matrix_result = { {true, false, true}, - {false, true, true}, + {true, true, false}, {false, false, false}, }; @@ -32,7 +32,7 @@ class PieceTest { boolean[][] piece3_matrix_result = { {false, false, false}, - {true, true, false}, + {false, true, true}, {true, false, true}, };