public Crawler(GameContainer gc, PlayMap playMap) { this.playMap = playMap; playMap.addMapListener( new MapListener() { public void cellChanged(int tx, int ty, Cell cell) { updatePath(); if (Cell.FINISH.equals(cell)) { finish.setX(tx); finish.setY(ty); updatePath(); } } }); }
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); } }