简易版扫雷程序代码publicclassMineSweeperGame2extendsApplication{Cell[][]cell;inttotalMines=0;intmarkBomb=0;//总的地雷数量,简单会有10个,一般会有40个,困难99个intshowMines=10;Strings=String.valueOf(showMines);Labeltips=newLabel("Gameisrunning!");LabelshowMineNum=newLabel("mines:"+s);publicvoidstart(StageprimaryStage){StagestartStage=newStage();//选择按钮的界面ButtonstartButton=newButton("RESTART");Buttonchooseeasy=newButton("EASY(10mines)");Buttonchoosenormal=newButton("NORMAL(40mines)");Buttonchoosehard=newButton("HARD(99mines)");BorderPaneprimaryPane=newBorderPane();HBoxstartPane=newHBox(15);StackPanetopButtonPane=newStackPane(startButton);StackPanetopButtonPane2=newStackPane(showMineNum);StackPanebuttomPane=newStackPane(tips);HBoxtopPane=newHBox(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(newInsets(15,15,15,15));topPane.setPadding(newInsets(15,15,15,15));startPane.setPadding(newInsets(15,15,15,15));startPane.getChildren().add(chooseeasy);startPane.getChildren().add(choosenormal);
2023/8/24 13:54:33
12KB
java
1