31 lines
825 B
Java
Raw Normal View History

package school_project;
public class Piece extends Shape{
private int x,y; // Position in the Map Object
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];
for (int i = 0; i < width; i++) {
for (int j = 0; j < height; j++) {
temp_matrix[i][j] = matrix[-j+height-1][i];
}
}
times--;
matrix = temp_matrix;
}
}
}