Exemple #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);
     }
   }
 }
Exemple #2
0
 @Before
 public void setUp() {
   map = new Map();
   final int rowLength = 9;
   final int columnLength = 5;
   this.right = new Tile[columnLength][rowLength];
   System.out.println(map.getMap()[1][1].getY());
   for (int row = 0; row < columnLength; row++) {
     for (int col = 0; col < rowLength; col++) {
       if ((col == 2 && row == 0) || (col == 8 && row == 2) || (col == 1 && row == 1)) {
         right[row][col] = new Tile(Terrain.MOUNTAIN1, col * WIDE, row * TALL);
       } else if ((row == 3 && (col == 1 || col == 6)) || (row == 4 && (col == 2 || col == 8))) {
         right[row][col] = new Tile(Terrain.MOUNTAIN2, col * WIDE, row * TALL);
       } else if ((row == 0 && col == 6) || (row == 1 && col == 8) || (row == 2 && col == 0)) {
         right[row][col] = new Tile(Terrain.MOUNTAIN3, col * WIDE, row * TALL);
       } else if (col == 4 && (row == 0 || row == 1 || row == 3 || row == 4)) {
         right[row][col] = new Tile(Terrain.RIVER, col * WIDE, row * TALL);
       } else if (!(row == 2 && col == 4)) {
         right[row][col] = new Tile(Terrain.PLAIN, col * WIDE, row * TALL);
       }
     }
   }
 }