Esempio n. 1
0
  // override this to catch stop falling events
  protected void stopped_falling() {
    if (colliding_box_ != null) {
      y_ =
          colliding_box_.y()
              - colliding_box_.get_height() / 2
              - Settings.BOX_GAP
              - get_height() / 2;
    }

    if (drive_this_height_ != null) drive_this_height_.set_y(y_);
  }
Esempio n. 2
0
  public void update() {
    if (left_driving_box_ != null) {
      x_ =
          left_driving_box_.x()
              + left_driving_box_.get_width() / 2
              + Settings.BOX_GAP
              + get_width() / 2;
      y_ = left_driving_box_.y();
    } else if (falling_) update_position();

    if (height_driver_ != null) y_ = height_driver_.y();

    check_off_screen();
  }
Esempio n. 3
0
  // used by the larger boxes to check collisions
  protected Collision check_collisions_with_center(float new_x, float new_y) {
    Iterator<Box> it = BoxManager.instance().boxes().iterator();

    while (it.hasNext()) {
      Box b = it.next();

      if (b == this) continue;

      if (b.ignore_collisions()) continue;

      if (b.is_inside(new_x, new_y + get_height() / 2 + Settings.BOX_GAP)) {
        colliding_box_ = b;
        return Collision.YES;
      } else if (false
          && b.is_inside(new_x, (int) (new_y + get_height() / 2 + last_fall_speed_ * 2.0)))
        return Collision.ABOUT;
    }

    return Collision.NONE;
  }
 public void run() {
   for (Box b : boxes) {
     b.display();
   }
 }
Esempio n. 5
0
  public boolean collides_with_box(Box box) {
    if (box == this) return false;

    return get_rectangle().intersects(box.get_rectangle());
  }