예제 #1
0
  public AStar(Grid grid) {

    this.grid = grid;
    this.heuristic = new Heuristic();

    this.searched = new ArrayList();
    this.frontier = new FrontierQueue();

    this.guiFrontier = new FrontierQueue();

    // init blocks
    this.blocks = new Block[grid.getGridWidth()][grid.getGridHeight()];
    for (int i = 0; i < grid.getGridWidth(); i++) {

      for (int j = 0; j < grid.getGridHeight(); j++) {

        this.blocks[i][j] = new Block(i, j);
      }
    }
  }
예제 #2
0
  /**
   * Constructs the panel
   *
   * @param game is the main game object
   * @param grid is the 2D array of blocks
   */
  public GridPanel(GameLogic game, Grid grid) {

    super();

    this.game = game;
    this.grid = grid;
    // add listener
    addKeyListener(this);

    setPreferredSize(new Dimension(grid.getGridWidth(), grid.getGridHeight()));

    setFocusable(true);
    setVisible(true);
  }