Exemplo n.º 1
0
 /**
  * Creates a Pathfinder object
  *
  * @param map Map to pathfind in
  */
 public PathFinder(Map map) {
   this.tiles = new boolean[map.getWidth()][map.getHeight()];
   this.graph = new Node[map.getWidth()][map.getHeight()];
   this.tileMap = map.getMap();
   for (int x = 0; x < tiles.length; x++) {
     for (int y = 0; y < tiles[0].length; y++) {
       this.tiles[y][x] = ((this.tileMap[x][y] & (1 << 14)) != 0);
       this.graph[x][y] = new Node(y, x);
     }
   }
 }
Exemplo n.º 2
0
 public void paintComponent(Graphics g) {
   super.paintComponent(g);
   for (int y = 0; y < map.getHeight(); y++) {
     for (int x = 0; x < map.getWidth(); x++) {
       Point p = new Point(x, y);
       Food f = map.getFood(p);
       float foodval = (f == null ? 0.0f : f.getRemaining());
       g.setColor(getPherColour(map.getPher(p), map.getNumAnts(p), foodval));
       g.fillRect(x * TILESIZE, y * TILESIZE, TILESIZE, TILESIZE);
     }
   }
 }