91av视频/亚洲h视频/操亚洲美女/外国一级黄色毛片 - 国产三级三级三级三级

  • 大小: 12KB
    文件類型: .java
    金幣: 2
    下載: 1 次
    發(fā)布日期: 2021-11-24
  • 語言: Java
  • 標(biāo)簽: java??

資源簡介

簡易版掃雷程序代碼 public class MineSweeperGame2 extends Application { Cell[][] cell; int totalMines=0; int markBomb=0; //總的地雷數(shù)量,簡單會有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);

資源截圖

代碼片段和文件信息


import?javafx.application.Application;
import?javafx.geometry.Insets;
import?javafx.scene.Scene;
import?javafx.stage.Stage;
import?javafx.scene.layout.GridPane;
import?javafx.scene.layout.StackPane;
import?javafx.scene.text.Text;
import?javafx.scene.layout.Pane;
import?javafx.scene.layout.BorderPane;
import?javafx.scene.layout.HBox;
import?javafx.scene.control.Button;
import?javafx.scene.control.Label;
import?javafx.scene.input.MouseButton;

public?class?MineSweeperGame2?extends?Application?{
Cell[][]?cell;
int?totalMines=0;
int?markBomb=0;???????????????????????????//總的地雷數(shù)量,簡單會有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(topButtonPanetopButtonPane2);

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(15151515));
topPane.setPadding(new?Insets(15151515));
startPane.setPadding(new?Insets(15151515));
startPane.getChildren().add(chooseeasy);
startPane.getChildren().add(choosenormal);
startPane.getChildren().add(choosehard);

startButton.setOnAction(e->{?
startStage.show();
tips.setText(“Game?is?running!!!“);???????????????//界面下方提示語
});

chooseeasy.setOnAction(e->{???????????????????????????//簡單按鈕實現(xiàn)9*9的游戲面板,設(shè)計成11*11是為了讓后面的功能容易實現(xiàn)
GridPane?minePane1=new?GridPane();
showMines=10;
s=String.valueOf(showMines);
showMineNum.setText(“mines:?“+s);
cell=new?Cell[11][11];
for(int?i=0;i<11;i++){
for(int?j=0;j<11;j++){
cell[i][j]=new?Cell(ij);
cell[i][j].getChildren().add(cell[i][j].text);???//每一個地雷格子需要有一個控制顯示的text
}
}
for(int?i=1;i<10;i++){
for(int?j=1;j<10;j++){
cell[i][j].isUsed=true;
minePane1.add(cell[i][j]?i-1?j-1);???//顯示輸出除了最外圍一圈的格子
}
}
createGameBoard(cell);
primaryPane.setCenter(minePane1);
startStage.close();
primaryStage.show();

});
choosenormal.setOnAction(e->{?????????????????????//普通按鈕實現(xiàn)16*16的游戲面板,設(shè)計成18*18是為了讓后面的功能容易實現(xiàn)
GridPane?minePane2=new?GridPane();
showMines=40;
s=String.valueOf(showMines);
showMineNum.setText(“mines:?“+s);
cell=new?Cell[18][18];
for(int?i

評論

共有 條評論

相關(guān)資源