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