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; private Map linked_map; public Piece() { super(); } public Piece(boolean[][] matrix) { super(matrix); } public Vec2 getPosition() { return Position; } public void setPosition(Vec2 position){ if (linked_map == null) { return; } this.Position = position; } /** * set the map the piece is into the the map argument * @param map map where to place the piece */ public void setLinked_map(Map map){ this.linked_map = map; } /** * 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; } } }