package school_project; import javafx.geometry.Insets; import javafx.geometry.Pos; import javafx.scene.Group; import javafx.scene.input.MouseButton; import javafx.scene.layout.BorderPane; import javafx.scene.layout.HBox; import javafx.scene.paint.Color; import javafx.stage.Screen; 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); grid.setLayoutX(Screen.getPrimary().getBounds().getWidth()/2 - grid.boundary_size.x/2); grid.setLayoutY(Screen.getPrimary().getBounds().getHeight()/2 - grid.boundary_size.y/2); Group pieces = new Group(); 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()); }); pieces.getChildren().add(_piece); } getChildren().addAll(grid, pieces); } }