示例#1
0
文件: Crawler.java 项目: xflash/tg
 private Path updatePath() {
   //        playMap.clearVisit();
   System.out.println("Crawler = " + start);
   path = pathFinder.findPath(this, start.getX(), start.getY(), finish.getX(), finish.getY());
   System.out.println(
       "UpdatePath : " + (path == null ? "none" : " path length " + path.getLength()));
   pathIdx = 0;
   return path;
 }
示例#2
0
文件: Crawler.java 项目: xflash/tg
 public void update(GameContainer gc, int frame) {
   timr += frame;
   if (timr > 500) {
     if (path != null) {
       pathIdx = Math.min(path.getLength(), pathIdx + 1);
       pathStep = path.getStep(pathIdx - 1);
       start.setX(pathStep.getX());
       start.setY(pathStep.getY());
     }
     timr = 0;
   }
 }
示例#3
0
文件: Crawler.java 项目: xflash/tg
  public void render(GameContainer gc, Graphics gfx) throws SlickException {
    Point pt = playMap.getPos();
    if (path != null) {
      for (int i = 0; i < path.getLength(); i++) {
        Path.Step step = path.getStep(i);
        gfx.setColor(Color.white);
        gfx.drawRect(
            pt.getX() + step.getX() * playMap.getTileWidth(),
            pt.getY() + step.getY() * playMap.getTileHeight(),
            playMap.getTileWidth(),
            playMap.getTileHeight());
      }
    }

    if (pathStep != null) {
      Point foe = new Point(pt);
      gfx.drawOval(
          foe.getX() + pathStep.getX() * playMap.getTileWidth() + 4,
          foe.getY() + pathStep.getY() * playMap.getTileHeight() + 4,
          9,
          9);
    }
  }