首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > JAVA > J2SE开发 >

java小游戏吃豆子算法有关问题

2011-12-24 
java小游戏吃豆子算法问题 以下代码鬼自由跑-需要鬼一出来就在不停的计算离人最近的路线,然后过去抓住人.

java小游戏吃豆子算法问题

以下代码鬼自由跑->
需要
鬼一出来就在不停的计算离人最近的路线,然后过去抓住人.
我找个直线算法
http://www.learnjava.cn/Article/j2se/jinjie/200706/221.html   参考

初次接触望大大给与帮助
由于论坛字数限制     特把源代码存入网易163.com中ceshi_yonghu@163.com  
用户名/密码   :     ceshi_yonghu/yonghu     修改完在存与油箱中,感谢,请不要修改用户及密码谢谢合作
import   java.awt.*;
import   java.applet.Applet;

public   class   PacMan   extends   Applet   implements   Runnable
{
    Dimensiond;
    Font   largefont   =   new   Font( "Helvetica ",   Font.BOLD,   24);
    Fontsmallfont   =   new   Font( "Helvetica ",   Font.BOLD,   14);

    FontMetricsfmsmall,   fmlarge;    
    Graphicsgoff;
    Imageii;
    Threadthethread;
    MediaTracker     thetracker   =   null;
    Colordotcolor=new   Color(192,192,0);
    intbigdotcolor=192;
    intdbigdotcolor=-2;
    Colormazecolor;

    booleaningame=false;
    booleanshowtitle=true;
    boolean               scared=false;
    boolean               dying=false;

    final   intscreendelay=120;
    final   int           blocksize=24;
    final   int           nrofblocks=15;
    final   int           scrsize=nrofblocks*blocksize;
    final   intanimdelay=8;
    final   int           pacanimdelay=2;
    final   int           ghostanimcount=2;
    final   int           pacmananimcount=4;
    final   int           maxghosts=12;
    final   intpacmanspeed=6;

    intanimcount=animdelay;
    int                       pacanimcount=pacanimdelay;
    intpacanimdir=1;
    intcount=screendelay;
    intghostanimpos=0;
    intpacmananimpos=0;
    intnrofghosts=6;
    intpacsleft,score;
    intdeathcounter;
    int[]dx,dy;
    int[]ghostx,   ghosty,   ghostdx,   ghostdy,   ghostspeed;

    Imageghost1,ghost2,ghostscared1,ghostscared2;
    Imagepacman1,   pacman2up,   pacman2left,   pacman2right,   pacman2down;
    Imagepacman3up,   pacman3down,   pacman3left,   pacman3right;
    Imagepacman4up,   pacman4down,   pacman4left,   pacman4right;

    intpacmanx,   pacmany,   pacmandx,   pacmandy;
    intreqdx,   reqdy,   viewdx,   viewdy;
    intscaredcount,   scaredtime;
    finalintmaxscaredtime=120;
    final   int           minscaredtime=20;

    final   short       level1data[]   =   {  
19,26,26,22,   9,12,19,26,22,   9,12,19,26,26,22,


37,11,14,17,26,26,20,15,17,26,26,20,11,14,37,
17,26,26,20,11,   6,17,26,20,   3,14,17,26,26,20,
21,   3,   6,25,22,   5,21,   7,21,   5,19,28,   3,   6,21,
21,   9,   8,14,21,13,21,   5,21,13,21,11,   8,12,21,
25,18,26,18,24,18,28,   5,25,18,24,18,26,18,28,
  6,21,   7,21,   7,21,11,   8,14,21,   7,21,   7,21,03,
  4,21,   5,21,   5,21,11,10,14,21,   5,21,   5,21,   1,
12,21,13,21,13,21,11,10,14,21,13,21,13,21,   9,
19,24,26,24,26,16,26,18,26,16,26,24,26,24,22,
21,   3,   2,   2,   6,21,15,21,15,21,   3,   2,   2,06,21,
21,   9,   8,   8,   4,17,26,   8,26,20,   1,   8,   8,12,21,
17,26,26,22,13,21,11,   2,14,21,13,19,26,26,20,
37,11,14,17,26,24,22,13,19,24,26,20,11,14,37,
25,26,26,28,   3,   6,25,26,28,   3,   6,25,26,26,28     };

    final   intvalidspeeds[]   =   {   1,2,3,4,6,6   };
    final   intmaxspeed=6;

由于论坛字数限制     特把源代码存入网易163.com中ceshi_yonghu@163.com  
用户名/密码   :     ceshi_yonghu/yonghu     修改完在存与油箱中,感谢,请不要修改用户及密码谢谢合作



[解决办法]
顶一个!
[解决办法]

热点排行