Finishing RotateRight

Signed-off-by: Anthony Debucquoy <debucquoy.anthony@gmail.com>
This commit is contained in:
Debucquoy Anthony 2023-02-27 11:05:32 +01:00 committed by Anthony Debucquoy
parent e06abe60de
commit 498529f29a
Signed by: tonitch
GPG Key ID: A78D6421F083D42E
2 changed files with 5 additions and 6 deletions

View File

@ -12,16 +12,15 @@ public class Piece extends Shape{
/** /**
* Rotate the matrix of the piece. Used when the player right click * Rotate the matrix of the piece. Used when the player right click
* TODO: ALGORITHME INCORECTE, A REFAIRE <tonitch>
* *
* @param times Set the amount of time the rotation should be executed. Should be set between 1 and 3. * @param times Set the amount of time the rotation should be executed. Should be set between 1 and 3.
*/ */
public void RotateRight(int times){ public void RotateRight(int times){
while(times > 0) { while(times > 0) {
boolean[][] temp_matrix = new boolean[width][height]; boolean[][] temp_matrix = new boolean[width][height];
for (int i = 0; i < height; i++) { for (int i = 0; i < width; i++) {
for (int j = 0; j < width; j++) { for (int j = 0; j < height; j++) {
temp_matrix[j][i] = matrix[i][j]; temp_matrix[i][j] = matrix[-j+height-1][i];
} }
} }
times--; times--;

View File

@ -16,7 +16,7 @@ class PieceTest {
boolean[][] piece1_matrix_result = { boolean[][] piece1_matrix_result = {
{true, false, true}, {true, false, true},
{false, true, true}, {true, true, false},
{false, false, false}, {false, false, false},
}; };
@ -32,7 +32,7 @@ class PieceTest {
boolean[][] piece3_matrix_result = { boolean[][] piece3_matrix_result = {
{false, false, false}, {false, false, false},
{true, true, false}, {false, true, true},
{true, false, true}, {true, false, true},
}; };