package school_project; import javafx.scene.Group; import javafx.scene.input.MouseButton; import school_project.Utils.MatrixShape; import java.io.FileNotFoundException; public class GameUI extends Group{ public final static int SEGMENT_SIZE = 50; public final static int SPACE_SIZE = 5; public GameUI(Map level) throws FileNotFoundException { super(); MatrixShape grid = new MatrixShape(level); //center the grid grid.setLayoutX((Controller.screen_size.x - grid.boundary_size.x) >> 1); grid.setLayoutY((Controller.screen_size.y - grid.boundary_size.y) >> 1); getChildren().add(grid); for (Piece p : level.getPieces()) { MatrixShape _piece = new MatrixShape(p); _piece.setOnMouseClicked(event -> { if(event.getButton() == MouseButton.SECONDARY){ ((Piece) _piece.shape).RotateRight(1); _piece.update(); } }); _piece.setOnMouseDragged(event -> { _piece.setLayoutX(event.getSceneX()); _piece.setLayoutY(event.getSceneY()); }); getChildren().add(_piece); } } }