コード例 #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_);
  }
コード例 #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();
  }
コード例 #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;
  }
コード例 #4
0
 public void run() {
   for (Box b : boxes) {
     b.display();
   }
 }
コード例 #5
0
  public boolean collides_with_box(Box box) {
    if (box == this) return false;

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