2023-02-27 00:52:19 +01:00
|
|
|
package school_project;
|
|
|
|
|
|
|
|
public class Piece extends Shape{
|
|
|
|
|
2023-02-27 11:22:07 +01:00
|
|
|
private int x,y; // Position in the Map Object
|
2023-02-27 00:52:19 +01:00
|
|
|
public Piece() {
|
|
|
|
super();
|
|
|
|
}
|
|
|
|
|
|
|
|
public Piece(boolean[][] matrix) {
|
|
|
|
super(matrix);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Rotate the matrix of the piece. Used when the player right click
|
|
|
|
*
|
|
|
|
* @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];
|
2023-02-27 11:05:32 +01:00
|
|
|
for (int i = 0; i < width; i++) {
|
|
|
|
for (int j = 0; j < height; j++) {
|
|
|
|
temp_matrix[i][j] = matrix[-j+height-1][i];
|
2023-02-27 00:52:19 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
times--;
|
|
|
|
matrix = temp_matrix;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|