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; }
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); } }