简易版扫雷程序代码
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);
2019-12-21 20:08:49
12KB
java
1