You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Nov 26, 2024. It is now read-only.
The ball should bounce. For now, a simple bouncing mechanism would simply be:
if the ball would meet the ground while falling, it bounces back up by the remaining falling distance
// issue 65 - The ball bounces// Before solving this test, make sure that solution for issue_15 has been merged here
{
ball b;
constdouble bounce_speed = 1.0;
// If the ball is high enough, it simply dropsconstdouble initial_y = 1.2; // that is, higher than the drop rate
b.set_y(initial_y);
b.drop(bounce_speed);
constdouble y_first_bounce = y_high - bounce_speed
assert(b.get_y() == y_first_bounce);
// If the ball would touch the ground, it bounces by the remaining distance
b.drop(bounce_speed);
constdouble y_second_bounce = abs(y_first_bounce - bounce_speed);
assert(b.get_y == y_second_bounce);
}
The text was updated successfully, but these errors were encountered:
The ball should bounce. For now, a simple bouncing mechanism would simply be:
The text was updated successfully, but these errors were encountered: