private void update_position() { Collision collision_result = check_collisions(); switch (collision_result) { case NONE: y_ += BoxManager.instance().current_fall_speed(); break; case ABOUT: y_ += 1; break; case YES: default: falling_ = false; if (falling_off_screen_) BoxManager.instance().delete_me(this); else stopped_falling(); break; } }
// 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; }
private void check_off_screen() { if (x_ - get_height() > VoteVisApp.instance().height) BoxManager.instance().delete_me(this); // TODO: check for all references in other managers }