public void createWallLine(int y) { PositionButton button; Pane wallRec; for (int x = 0; x < 8; x++) { wallRec = new Pane(); wallRec.setPrefSize(30, 10); wallRec.setId("wallRec"); horizontalWalls[x][y] = wallRec; gameGrid.setConstraints(horizontalWalls[x][y], column, row); gameGrid.getChildren().add(horizontalWalls[x][y]); column++; button = new WallPositionButton(new Position(x, y)); button.setPrefSize(10, 10); button.setId("wallPosBtn"); wallPositionButtons[x][y] = button; gameGrid.setConstraints(wallPositionButtons[x][y], column, row); gameGrid.getChildren().addAll(wallPositionButtons[x][y]); column++; } wallRec = new Pane(); wallRec.setPrefSize(30, 10); wallRec.setId("wallRec"); horizontalWalls[8][y] = wallRec; gameGrid.setConstraints(horizontalWalls[8][y], column, row); gameGrid.getChildren().add(horizontalWalls[8][y]); column = 0; row++; }
public void createMoveLine(int y) { PositionButton button; Pane wallRec; button = new PlayerPositionButton(new Position(0, y)); button.setPrefSize(60, 60); button.setId("board"); playerPositionButtons[0][y] = button; gameGrid.setConstraints(button, column, row); gameGrid.getChildren().addAll(playerPositionButtons[0][y]); for (int x = 1; x < 9; x++) { column++; wallRec = new Pane(); wallRec.setPrefSize(10, 30); wallRec.setId("wallRec"); verticalWalls[x][y] = wallRec; gameGrid.setConstraints(wallRec, column, row); gameGrid.getChildren().add(verticalWalls[x][y]); column++; button = new PlayerPositionButton(new Position(x, y)); button.setPrefSize(60, 60); button.setId("board"); playerPositionButtons[x][y] = button; gameGrid.setConstraints(button, column, row); gameGrid.getChildren().addAll(playerPositionButtons[x][y]); } column = 0; row++; }
public BoardView(int noPlayers, final Stage primaryStage) { window = primaryStage; window.setTitle("Quoridor"); window.setMaxHeight(1280); window.setMaxWidth(1280); window.setResizable(false); BorderPane border = new BorderPane(); infoPane = new FlowPane(); infoPane.setPadding(new Insets(10)); infoPane.setHgap(40); infoPane.setVgap(10); infoPane.setOrientation(Orientation.HORIZONTAL); bottomPane = new HBox(); bottomPane.setSpacing(345); gameGrid = new GridPane(); gameGrid.setPadding(new Insets(4)); gameGrid.setId("gamegrid"); border.setTop(infoPane); border.setCenter(gameGrid); playerPositionButtons = new PlayerPositionButton[9][9]; wallPositionButtons = new WallPositionButton[9][8]; horizontalWalls = new Pane[9][9]; verticalWalls = new Pane[9][9]; column = 0; row = 0; chooseVertical = new Button(); chooseVertical.setPrefSize(100, 100); chooseVertical.setId("vWallBtn"); Button home = new Button(); home.setPrefSize(100, 100); home.setId("home"); home.setOnAction(e -> confirmBox()); bottomPane.getChildren().addAll(chooseVertical, home); border.setBottom(bottomPane); border.setMargin(bottomPane, new Insets(40, 40, 20, 20)); for (int y = 0; y < 8; y++) { createMoveLine(y); createWallLine(y); } createMoveLine(8); main = new Scene(border, 600, 768); main.getStylesheets().add("gameplay/viewJFX/" + stylesheet); buildPlayerLabels(noPlayers); window.setScene(main); window.show(); }