예제 #1
0
 /**
  * check if human collides with a ghost
  *
  * @param game
  * @return the ghost where the human collides with
  */
 public Ghost checkGhostCollision(Game game) {
   // ghost collision
   for (Ghost ghost : game.getGhosts()) {
     if (!ghost.getRip() && !ghost.getDead()) {
       if (checkHitboxCollision(this.getPosition(), 90, 90, ghost.getPosition(), 90, 90)) {
         return ghost;
       }
     }
   }
   return null;
 }
예제 #2
0
파일: Grid.java 프로젝트: ma-wo/comp-geo
 public void update(List<Point> ghostPositions) {
   for (int i = 0; i < ghosts.size(); ++i) {
     Ghost ghost = ghosts.get(i);
     Cell currentCell = getCell(ghost.getPosition());
     Cell newCell = getCell(ghostPositions.get(i));
     if (!currentCell.equals(newCell)) {
       grid.get(currentCell.row).get(currentCell.column).remove(ghost);
       grid.get(newCell.row).get(newCell.column).add(ghost);
     }
   }
 }
예제 #3
0
파일: Grid.java 프로젝트: ma-wo/comp-geo
  private void build(List<Ghost> ghosts) {
    grid = new ArrayList<List<List<Ghost>>>();
    for (int i = 0; i < nRows; ++i) {
      List<List<Ghost>> columns = new ArrayList<List<Ghost>>();
      for (int j = 0; j < nColumns; ++j) {
        columns.add(new LinkedList<Ghost>());
      }
      grid.add(columns);
    }

    for (Ghost ghost : ghosts) {
      Cell c = getCell(ghost.getPosition());
      grid.get(c.row).get(c.column).add(ghost);
    }
  }