44 lines
1.1 KiB
Java
Raw Normal View History

package school_project;
/**
* Represent a Piece in the game.
* Every Piece should be contained in a Map Object.
* A piece has a position witch is the position of its top-leftest position in its matrix.
* If the piece is not placed in the Map (in a floating state) the position should be null;
*/
public class Piece extends Shape{
private Vec2 Position;
public Piece() {
super();
}
public Piece(boolean[][] matrix) {
super(matrix);
}
public Vec2 getPosition() {
return Position;
}
public void getPo
/**
* 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;
}
}
}