Exemplo n.º 1
0
  public boolean contains(Obstacle o) {
    // ---------------------------------------------------
    // Not to add two obstacle for same location
    // --------------------------------------------------
    double distanceY = o.getCenterY() - centerY;
    double distanceX = o.getCenterX() - centerX;

    double distanceWidth = (o.getWidth() + width) / 2;
    double distanceHeight = (o.getHeight() + height) / 2;

    if (distanceWidth <= distanceX && distanceHeight <= distanceY) {
      return true;
    } else return false;
  }