- void constrain_left (float left2 ) { left = std::max(left , left2 ); }
- void constrain_right (float right2 ) { right = std::min(right , right2 ); }
- void constrain_top (float top2 ) { top = std::max(top , top2 ); }
- void constrain_bottom(float bottom2) { bottom = std::min(bottom, bottom2); }
+ void constrain_left (float position, float velocity)
+ {
+ position_left = std::max (position_left, position);
+ speed_left = std::max (speed_left, velocity);
+ }
+
+ void constrain_right (float position, float velocity)
+ {
+ position_right = std::min (position_right, position);
+ speed_right = std::min (speed_right, velocity);
+ }
+
+ void constrain_top (float position, float velocity)
+ {
+ position_top = std::max (position_top, position);
+ speed_top = std::max (speed_top, velocity);
+ }
+
+ void constrain_bottom (float position, float velocity)
+ {
+ position_bottom = std::min (position_bottom, position);
+ speed_bottom = std::min (speed_bottom, velocity);
+ }
+
+ float get_position_left (void) const { return position_left; }
+ float get_position_right (void) const { return position_right; }
+ float get_position_top (void) const { return position_top; }
+ float get_position_bottom (void) const { return position_bottom; }
+
+ float get_height (void) const { return (position_bottom - position_top); }
+ float get_width (void) const { return (position_right - position_left); }
+
+ float get_x_midpoint (void) const { return (.5f * (position_left + position_right)); }