资源简介
基于广度优先算法,记录最短路径,实现《围猫》模式的小游戏
代码片段和文件信息
import java.awt.Font;
import java.awt.Graphics;
import java.awt.Toolkit;
import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;
import java.awt.image.BufferedImage;
import java.util.ArrayList;
import java.util.linkedList;
import java.util.List;
import java.util.Queue;
import java.util.Stack;
import javax.swing.Jframe;
import javax.swing.JOptionPane;
import javax.swing.plaf.SliderUI;
public class Armyframe extends Jframe implements Runnable MouseListener{
private static final long serialVersionUID = 1L;
//记录走的步数
private int stepCont = 0;
private List sceneList = new ArrayList();
private int sort;
private Thread freshThread = null;
private Place placeArr[][] = new Place[9][13];
private int currentX = 4 currentY = 6;
private int singelRow[][] = new int[6][2];
private int doubleRow[][] = new int[6][2];
public Armyframe(){
this.settitle(“赤壁之围曹操“);
this.setSize(640 480);
int width=Toolkit.getDefaultToolkit().getScreenSize().width;
int height=Toolkit.getDefaultToolkit().getScreenSize().height;
this.setLocation((width-640)/2(height-480)/2);
this.setDefaultCloseOperation(Jframe.EXIT_ON_CLOSE);
this.setVisible(true);
this.setResizable(false);
Scene startScene = new Scene(1 1);
sceneList.add(startScene);
Scene info1 = new Scene(2 2);
sceneList.add(info1);
Scene info2 = new Scene(3 2);
sceneList.add(info2);
Scene game = new Scene(4 2);
sceneList.add(game);
Scene end = new Scene(5 3);
sceneList.add(end);
this.sort = 0;
this.addMouseListener(this);
this.repaint();
//初始化6个方向数组,因为单数行和偶数行的方向不同,所以要做两个数组
singelRow[0][0] = -1;
singelRow[0][1] = -1;
singelRow[1][0] = -1;
singelRow[1][1] = 0;
singelRow[2][0] = 0;
singelRow[2][1] = 1;
singelRow[3][0] = 1;
singelRow[3][1] = 0;
singelRow[4][0] = 1;
singelRow[4][1] = -1;
singelRow[5][0] = 0;
singelRow[5][1] = -1;
doubleRow[0][0] = -1;
doubleRow[0][1] = 0;
doubleRow[1][0] = -1;
doubleRow[1][1] = 1;
doubleRow[2][0] = 0;
doubleRow[2][1] = 1;
doubleRow[3][0] = 1;
doubleRow[3][1] = 1;
doubleRow[4][0] = 1;
doubleRow[4][1] = 0;
doubleRow[5][0] = 0;
doubleRow[5][1] = -1;
freshThread = new Thread(this);
freshThread.start();
}
public void paint(Graphics g){
BufferedImage image=new BufferedImage(900600BufferedImage.TYPE_3BYTE_BGR);
Graphics g2=image.getGraphics();
if(sceneList.size() > sort){
Scene currentScene = sceneList.get(sort);
if(currentScene != null){
//先画背景
g2.drawImage(currentScene.getBgImage()00this);
//再画里边固定位置的元素
for(int i = 0; i < currentScene.getResorceList().size(); i++){
Resource tempResource = currentScene.getResorceList().get(i);
g2.drawImage(tempResource.getImage() tempResource.getX() tempResource.getY() this);
}
//画定点
placeArr = currentS
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
I.A.... 301 2015-12-10 09:03 RedArmy\.classpath
I.A.... 383 2015-12-10 09:03 RedArmy\.project
I.A.... 598 2015-12-10 09:03 RedArmy\.settings\org.eclipse.jdt.core.prefs
I.A.... 3 2015-12-10 09:03 RedArmy\.svn\entries
I.A.... 3 2015-12-10 09:03 RedArmy\.svn\format
I.A.... 2093 2015-12-10 09:03 RedArmy\.svn\pristine\04\041b13a6ba25679d9717dda6ccac77d00acc7ad8.svn-ba
I.A.... 1421 2015-12-10 09:03 RedArmy\.svn\pristine\06\068a4c0c2b7473aab30d998820a4bb613eb2e13a.svn-ba
I.A.... 569424 2015-12-10 09:03 RedArmy\.svn\pristine\10\10775280bbbb8c42bf31363fb0c24f8dc60f7b11.svn-ba
I.A.... 6379 2015-12-10 09:03 RedArmy\.svn\pristine\13\13383452ea43cd37975ebd87caa973a6fe18c972.svn-ba
I.A.... 145 2015-12-10 09:03 RedArmy\.svn\pristine\14\146c3b7e9bf995ba7759284b0c69e9a2766aec39.svn-ba
I.A.... 598 2015-12-10 09:03 RedArmy\.svn\pristine\17\1738f633fc4a9029a9b29c54a7d3fc9dfb4ca9cf.svn-ba
I.A.... 383 2015-12-10 09:03 RedArmy\.svn\pristine\23\230d5881f70ab4ed4810b3e12cc579e0c06aef2e.svn-ba
I.A.... 6314 2015-12-10 09:03 RedArmy\.svn\pristine\23\237ef4f372171596a66dc8ce013a6521c0115de3.svn-ba
I.A.... 145 2015-12-10 09:03 RedArmy\.svn\pristine\24\248497138150b07591db4830fd35904f0bbfad57.svn-ba
I.A.... 11520 2015-12-10 09:03 RedArmy\.svn\pristine\27\27db0560d2e3cb86720e472650af6134803797e2.svn-ba
I.A.... 158 2015-12-10 09:03 RedArmy\.svn\pristine\2c\2c3932ce67ed82a6411f8259fc938d1f35b78ed3.svn-ba
I.A.... 221 2015-12-10 09:03 RedArmy\.svn\pristine\3a\3ad6c1430f6beb16f6fa5ca4660bca22a3d545d3.svn-ba
I.A.... 9271 2015-12-10 09:03 RedArmy\.svn\pristine\4b\4b2f72a92064675aaaeac5fd70541400d30b3ffa.svn-ba
I.A.... 219216 2015-12-10 09:03 RedArmy\.svn\pristine\4f\4f86d0f29aca79e1fcc50b512cfbf023cb05164d.svn-ba
I.A.... 509069 2015-12-10 09:03 RedArmy\.svn\pristine\6f\6ff2fb585ca3819cb78bcf3c155e6ecf6263c5e5.svn-ba
I.A.... 100266 2015-12-10 09:03 RedArmy\.svn\pristine\82\8214ae57fd13bff60f34b09ab0acb7143d40fc4d.svn-ba
I.A.... 301 2015-12-10 09:03 RedArmy\.svn\pristine\93\9362e57b11f40e949fe976d0434a78c828fd6a4f.svn-ba
I.A.... 117274 2015-12-10 09:03 RedArmy\.svn\pristine\a1\a19ac6d4ef81bab3945886a3a403dc512cb4581f.svn-ba
I.A.... 93784 2015-12-10 09:03 RedArmy\.svn\pristine\a6\a6dc3917990d2c71b9f06176cef6b72c9658efcf.svn-ba
I.A.... 615255 2015-12-10 09:03 RedArmy\.svn\pristine\ad\add032f9de30d77a77239a9b1465d74b003e3dc9.svn-ba
I.A.... 250840 2015-12-10 09:03 RedArmy\.svn\pristine\d2\d24cf83d1a39b7609d8bf308dcc65def3757ba87.svn-ba
I.A.... 3373 2015-12-10 09:03 RedArmy\.svn\pristine\d5\d529e4d4400eb41f233f951a17474198d29836be.svn-ba
I.A.... 141 2015-12-10 09:03 RedArmy\.svn\pristine\e8\e897b8c934c8013f5acefdee36b4127ede7bc412.svn-ba
I.A.... 625 2015-12-10 09:03 RedArmy\.svn\pristine\f6\f661561179fcd3ec1cf4586d212c4a2b99470eb5.svn-ba
I.A.... 49152 2015-12-10 09:03 RedArmy\.svn\wc.db
............此处省略77个文件信息
相关资源
- 最新POI Lib Java Excel转换成Txt
- java分布式程序设计
- java对打小游戏界面漂亮
- netdisk 网盘 java 毕业设计 2018最新版
- 基于java的opengl计算机图形学学习资料
- thinking in java 英文版
- JAVA JDK6学习笔记 林信良 良葛格 含
- 时钟日历java
- JavaEE简单的论坛源码太简单,无留言
-
JAVA(jsp+servlet+ja
vasc ript)超市商品 - JAVA JSP牛奶配送管理系统 源代码 论文
- JAVA JSP景区订票系统 源代码 论文
- Java GUI
- 基于java的在线答疑系统
- Aspose word for java-14.11最新完美破解版,
- 图解数据结构使用Java.zip
- 超级漂亮java Swing UI 源码
- java手机游戏50例代码
- javaweb网上书城源码(包含数据库)
- JavaEE开发的颠覆者 Spring Boot实战源代
- java学习笔记全
- java2实用教程(第四版)耿祥义ppt课件
- Java经典面试题 传智播客
- Java反序列化漏洞利用工具全
- Java文件上传并自动解压
- 《java从入门到精通 高宏静版》适合初
- Java语言面向对象程序设计第2版清华大
- android 客户端访问java后台实现登陆,
- Java EE Web开发与项目实战code
- 基于Jsp网络在线考试系统源码
评论
共有 条评论