没有合适的资源?快使用搜索试试~ 我知道了~
基于递归算法自动生成迷宫,也可以从文件中读取数据生成迷宫,最后利用Javafx进行迷宫的填充
资源推荐
资源详情
资源评论
package desing;
import java.io.File;
import java.io.FileNotFoundException;
import java.util.ArrayList;
import java.util.Random;
import java.util.Scanner;
import javafx.application.Application;
import javafx.event.ActionEvent;
import javafx.event.EventHandler;
import javafx.geometry.HPos;
import javafx.geometry.Pos;
import javafx.scene.Scene;
import javafx.scene.control.Button;
import javafx.scene.control.TextField;
import javafx.scene.layout.GridPane;
import javafx.scene.layout.HBox;
import javafx.scene.layout.Pane;
import javafx.scene.paint.Color;
import javafx.scene.shape.Rectangle;
import javafx.scene.text.Text;
import javafx.stage.Stage;
class wall extends Pane{
private Rectangle square = new Rectangle();
public wall(int x,int y,int side) {
square.setWidth(side);
square.setHeight(side);
square.setX(x);
import java.io.File;
import java.io.FileNotFoundException;
import java.util.ArrayList;
import java.util.Random;
import java.util.Scanner;
import javafx.application.Application;
import javafx.event.ActionEvent;
import javafx.event.EventHandler;
import javafx.geometry.HPos;
import javafx.geometry.Pos;
import javafx.scene.Scene;
import javafx.scene.control.Button;
import javafx.scene.control.TextField;
import javafx.scene.layout.GridPane;
import javafx.scene.layout.HBox;
import javafx.scene.layout.Pane;
import javafx.scene.paint.Color;
import javafx.scene.shape.Rectangle;
import javafx.scene.text.Text;
import javafx.stage.Stage;
class wall extends Pane{
private Rectangle square = new Rectangle();
public wall(int x,int y,int side) {
square.setWidth(side);
square.setHeight(side);
square.setX(x);
square.setY(y);
square.setFill(Color.BLACK);
getChildren().add(square);
}
}
public class maze extends Application{
private Boolean isWall[][] = null; //显示迷宫的墙壁
private MazePane mazePane = null;
private Stage stage = null;
private Button manualMaze = new Button("手动生成迷宫");
private Button easy = new Button("简单");
private Button common = new Button("一般");
private Button hard = new Button("困难");
private Button automaticMaze = new Button("自动生成迷宫");
private Text rowText = new Text("行(奇数):");
private Text rankText = new Text("列(奇数):");
private TextField rowField = new TextField();
private TextField rankField = new TextField();
private Button btOk = new Button("确定");
public static void main(String[] args) {
launch(args);
}
//显示起始界面(外围墙),方法
public Boolean[][] initializeIsWall() {
Boolean isWall[][] = new Boolean[23][23];
for(int i = 0;i<isWall.length;i++) {
for(int j = 0;j<isWall[0].length;j++) {
square.setFill(Color.BLACK);
getChildren().add(square);
}
}
public class maze extends Application{
private Boolean isWall[][] = null; //显示迷宫的墙壁
private MazePane mazePane = null;
private Stage stage = null;
private Button manualMaze = new Button("手动生成迷宫");
private Button easy = new Button("简单");
private Button common = new Button("一般");
private Button hard = new Button("困难");
private Button automaticMaze = new Button("自动生成迷宫");
private Text rowText = new Text("行(奇数):");
private Text rankText = new Text("列(奇数):");
private TextField rowField = new TextField();
private TextField rankField = new TextField();
private Button btOk = new Button("确定");
public static void main(String[] args) {
launch(args);
}
//显示起始界面(外围墙),方法
public Boolean[][] initializeIsWall() {
Boolean isWall[][] = new Boolean[23][23];
for(int i = 0;i<isWall.length;i++) {
for(int j = 0;j<isWall[0].length;j++) {
剩余10页未读,继续阅读
资源评论
_aeiou_
- 粉丝: 0
- 资源: 1
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功