Here's the same code, except we've specified a zero x-velocity so it just bounces up and down on the spot, which makes it clearer there's a problem. Real balls don't rebound higher than they started (unless you hurl them down, which we're not doing here).
Our program says things rebound with the same amount of velocity, just in the opposite direction.
So how can this not be working properly?
|