{
for (int i = 0;inummax;++i)
{
char nextX,nextY;//下一步的坐标
nextX = queue[front].x + dx[i];
nextY = queue[front].y + dy[i];
//下一个节点可行
if (nextX = 0nextXrowsnextY = 0nextYcols0 == block[nextX][nextY])
{
//寻找到目标点
if (nextX == endXnextY == endY)
{
//生成路径
path[nextX][nextY] = 1;
int ParIn = front;
while(ParIn != -1)
{
path[queue[ParIn].x][queue[ParIn].y] = 1;
ParIn = queue[ParIn].parentNode;
}
//printPath();
}
//入栈
queue[rear].x = nextX;
queue[rear].y = nextY;
queue[rear].parentNode = front;
++rear;
//标记此点已被访问
block[nextX][nextY] = 1;
}
}
++front;
}
free(queue);
}
int _tmain(int argc, _TCHAR* argv[])
{
BFS();
printPath();
system("pause");
return 0;
}
在Java游戏中让一个人物走动的代码是什么?代码主要为以下java人物上下跳动代码:
package com.lovo.game.frame;
import java.awt.Graphics;
import java.awt.Image;
import java.awt.MediaTracker;
import javax.swing.JFrame;
import com.lovo.game.role.Fire;
import com.lovo.game.role.GameMap;
import com.lovo.game.role.ZhaoYun;
import com.lovo.game.util.TrackerInit;
public class GameStartFrame extends JFrame implements Runnable{
private Image memoryImage;
private Graphics memoryGraphics;
public static boolean isRun = true;
private static GameMap gameMap = new GameMap();
private ZhaoYun zy = new ZhaoYun();
private Fire fire = new Fire();
public GameStartFrame(){
this.setSize(900,700);
this.setVisible(true);
this.setDefaultCloseOperation(3);
//设置居中
this.setLocationRelativeTo(null);
//初始化双缓冲画布、画笔
this.memoryImage = this.createImage(900,700);
this.memoryGraphics = this.memoryImage.getGraphics();
//媒体追踪器
MediaTracker tracker = new MediaTracker(this);
TrackerInit.initImage(tracker);
//启动线程
Thread th = new Thread(this);
th.start();
}
public static void main(String[] args) {
GameStartFrame game = new GameStartFrame();
}
public void run() {
while(isRun){
this.flushFrame();
try {
Thread.sleep(20);
} catch (InterruptedException e) {
e.printStackTrace();
}
}
}
private void flushFrame(){
gameMap.drawMap(memoryGraphics);
zy.drawImage(memoryGraphics);
fire.drawImage(memoryGraphics);
//将双缓冲画布中java人物上下跳动代码的图片显示在窗体
this.getGraphics().drawImage(this.memoryImage,0,0,this);
}
}
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
package com.lovo.game.role;
import java.awt.Graphics;
import java.awt.Image;
public class GameMap {
public static Image mapImg;
public static int mapx;
public void drawMap(Graphics memoryGraphics){
mapx -=5;
if(mapx =-17100){
mapx = -17100;
}
memoryGraphics.drawImage(mapImg,mapx,0,null);
}
}
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
package com.lovo.game.role;
import java.awt.Graphics;
import java.awt.Image;
import com.lovo.game.util.MoveImageChange;
public class Fire {
public static Image[]fireImage;
private int x =100;
private int y =300;
private int width = 200;
private int height = 130;
private MoveImageChange moveChange = new MoveImageChange(3);
public void drawImage(Graphics memoryGraphics){
Image img = moveChange.imageChange(fireImage);
推荐阅读
- linux中各命令的意义,linux各种命令
- zblog插件原理,zblog插件破解插件
- 软件刚开直播电视,打开直播电视
- go语言slice使用 go语言strconv
- 关于c语言设计车辆限行的信息
- 欧版p40pro可以升级鸿蒙吗,欧版p40pro在国内可以用5g吗
- 宝宝巴士游戏老鼠大冒险,宝宝巴士小老鼠乡下老鼠
- 关于vb.net视频百度云盘的信息
- 魔幻车神什么视频能看,魔幻车神的影视