Learn Create Your Own Split Screen

Next Page

If you watched that program running for a few seconds, you may have noticed that there's a bit of a problem: the ball rebounds higher than where it started.

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?