tresinformal / basketball

Trêsinformal's 2024 team basketball game
GNU General Public License v3.0
0 stars 0 forks source link

The ball bounces #65

Open TheoPannetier opened 7 months ago

TheoPannetier commented 7 months ago

The ball should bounce. For now, a simple bouncing mechanism would simply be:

 // issue 65 - The ball bounces
  // Before solving this test, make sure that solution for issue_15 has been merged here
  {
    ball b;
    const double bounce_speed = 1.0;

    // If the ball is high enough, it simply drops
    const double initial_y = 1.2; // that is, higher than the drop rate
    b.set_y(initial_y);
    b.drop(bounce_speed);
    const double 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);
    const double y_second_bounce = abs(y_first_bounce - bounce_speed);
    assert(b.get_y == y_second_bounce);
  }
OggyOggelito commented 6 months ago

Saw right away there were some missing. But added it now.