可视化动态迷宫带音乐,可自定义迷宫


可视化动态迷宫(带音乐,可自定义迷宫),图形化迷宫
资源截图
代码片段和文件信息
import java.awt.Color;

import java.awt.Dimension;
import java.awt.Graphics;
import java.awt.Toolkit;
import java.awt.Image;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import java.net.URL;
import java.util.ArrayList;

import javax.swing.*;

public class CreatMaze {
//总体类似Drawframe 的自定义生成迷宫
// 0代表没路过,1代表第一次尝试的地方,3代表设置的墙,4代表走过2次的
static Thread t;
public Jframe index;
public MazeModel m;
public ArrayList maze;
private JLabel inputsize multi;
private JButton creat exi sloveone sloveall again save;
public JTextField input inputy;
private int realx = 0 realy = 0;// 迷宫的真实大小
private int sizex = 0 sizey = 0;// 对应迷宫的方格大小
final ImageIcon icon5;
ImageIcon iconapple;
ImageIcon buton1 buton2 buton3 buton4 buton5;
JPanel panel;
Image wa app;
URL apple;
CanvasPanel Pan;
boolean havecreat = false ifend enthread = true haveaddmouse = false;;
int screenWidth screenHeight;
int clickx clicky;
int runnumber = 0 firsttime = 0;
MazePoint[] path;
int choose = 0;
int width = 0;
boolean isModify = true;
private MazePoint now;
Jframe getframe;

public CreatMaze(Jframe temp) {//初始化图像
getframe=temp;

Pan = new CanvasPanel();
URL wall = this.getClass().getResource(“/墙壁.jpg“);
icon5 = new ImageIcon(wall);
wa = icon5.getImage();
apple = this.getClass().getResource(“/苹果1.jpg“);
iconapple = new ImageIcon(apple);
app = iconapple.getImage();
clickx = 0;
clicky = 0;

initializeThread();
initialize();

}

private void GetMaze(int x int y) {//生成迷宫
m = new MazeModel(x y);
maze = m.Initialize();
width = x;
now = new MazePoint(0 0);
enthread = true;
ifend = false;
}

private void initialize() {//初始化界面
index = new Jframe();

index.setResizable(false);
index.setDefaultCloseOperation(Jframe.EXIT_ON_CLOSE);

Toolkit kit = Toolkit.getDefaultToolkit(); // 定义工具包
Dimension screenSize = kit.getScreenSize(); // 获取屏幕的尺寸
screenWidth = screenSize.width / 2; // 获取屏幕的宽
screenHeight = screenSize.height / 2; // 获取屏幕的高

index.setBounds(screenWidth - 500 screenHeight - 310 1000 620);
index.setLayout(null);
index.settitle(“迷宫“);

final int portx = 830;

final int porth = 50;

inputsize = new JLabel(“输入迷宫范围(6-25)“);
input = new JTextField(6);
inputy = new JTextField(6);
inputsize.setBounds(portx 100 200 30);
input.setBounds(portx + 5 140 45 30);
inputy.setBounds(portx + 65 140 45 30);
multi = new JLabel(“ד);
multi.setBounds(portx + 54 140 15 30);

URL bu1 = this.getClass().getResource(“/生成.jpg“);
buton1 = new ImageIcon(bu1);
URL bu2 = this.getClass().getResource(“/单步.jpg“);
buton2 = new ImageIcon(bu2);
URL bu3 = this.getClass().getResource(“/退出.jpg“);
buton3 = new ImageIcon(bu3);
URL bu4 = this.getClass().getResource(“/重新演示.jpg“);

 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----

     文件        299  2012-02-15 12:33  Mazenew.classpath

     文件        383  2012-02-15 12:33  Mazenew.project

     文件        629  2012-02-15 12:33  Mazenew.settingsorg.eclipse.jdt.core.prefs

     文件        841  2012-03-27 20:42  MazenewinCreatMaze$1.class

     文件       1358  2012-03-27 20:42  MazenewinCreatMaze$2.class

     文件       2884  2012-03-27 20:42  MazenewinCreatMaze$CanvasPanel.class

     文件       2535  2012-03-27 20:42  MazenewinCreatMaze$CreatAction.class

     文件        730  2012-03-27 20:42  MazenewinCreatMaze$ExiAction.class

     文件        930  2012-03-27 20:42  MazenewinCreatMaze$MakeMazeAdapter.class

     文件       1426  2012-03-27 20:42  MazenewinCreatMaze$ReAction.class

     文件        752  2012-03-27 20:42  MazenewinCreatMaze$SaveAction.class

     文件       1235  2012-03-27 20:42  MazenewinCreatMaze$SloveallAction.class

     文件       1270  2012-03-27 20:42  MazenewinCreatMaze$SloveoneAction.class

     文件       7357  2012-03-27 20:42  MazenewinCreatMaze.class

     文件       1384  2012-03-27 20:11  MazenewinDrawframe$1.class

     文件        841  2012-03-27 20:11  MazenewinDrawframe$2.class

     文件       4043  2012-03-27 20:11  MazenewinDrawframe$CanvasPanel.class

     文件       2496  2012-03-27 20:11  MazenewinDrawframe$CreatAction.class

     文件        834  2012-03-27 20:11  MazenewinDrawframe$ExiAction.class

     文件       1199  2012-03-27 20:11  MazenewinDrawframe$ReAction.class

     文件       1343  2012-03-27 20:11  MazenewinDrawframe$SloveallAction.class

     文件       1218  2012-03-27 20:11  MazenewinDrawframe$SloveoneAction.class

     文件       6969  2012-03-27 20:11  MazenewinDrawframe.class

     文件        799  2012-03-27 20:11  MazenewinIndex$1.class

     文件        641  2012-03-27 20:11  MazenewinIndex$2.class

     文件        641  2012-03-27 20:11  MazenewinIndex$3.class

     文件       1202  2012-03-27 20:11  MazenewinIndex$ExiMouseAdapter.class

     文件       1195  2012-03-27 20:11  MazenewinIndex$MusicMouseAdapter.class

     文件       1318  2012-03-27 20:11  MazenewinIndex$StartMouseAdapter$1.class

     文件       1429  2012-03-27 20:11  MazenewinIndex$StartMouseAdapter.class

............此处省略63个文件信息

版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容, 请发送邮件举报,一经查实,本站将立刻删除。

发表评论

评论列表(条)