文件名称:简易版扫雷代码Java扫雷入门
文件大小:12KB
文件格式:JAVA
更新时间:2021-08-10 12:40:29
java
简易版扫雷程序代码 public class MineSweeperGame2 extends Application { Cell[][] cell; int totalMines=0; int markBomb=0; //总的地雷数量,简单会有10个,一般会有40个,困难99个 int showMines=10; String s=String.valueOf(showMines); Label tips=new Label("Game is running!"); Label showMineNum=new Label("mines: "+s); public void start(Stage primaryStage){ Stage startStage=new Stage(); //选择按钮的界面 Button startButton=new Button("RESTART"); Button chooseeasy=new Button(" EASY (10mines)"); Button choosenormal=new Button("NORMAL(40mines)"); Button choosehard=new Button(" HARD(99mines)"); BorderPane primaryPane=new BorderPane(); HBox startPane=new HBox(15); StackPane topButtonPane=new StackPane(startButton); StackPane topButtonPane2=new StackPane(showMineNum); StackPane buttomPane=new StackPane(tips); HBox topPane=new HBox(50); topPane.getChildren().addAll(topButtonPane,topButtonPane2); primaryPane.setTop(topPane); tips.setStyle("-fx-border-color:red;-fx-background-color:white;"); showMineNum.setStyle("-fx-border-color:black"); primaryPane.setBottom(buttomPane); buttomPane.setPadding(new Insets(15,15,15,15)); topPane.setPadding(new Insets(15,15,15,15)); startPane.setPadding(new Insets(15,15,15,15)); startPane.getChildren().add(chooseeasy); startPane.getChildren().add(choosenormal);