Bouncing Basketball

Objective:

Create an app that contains a box and a basketball bouncing inside of it with functionality that of a color changing ball and ability to adjust the speed of which the ball travels.

Problem:

How do we change the speed of the ball, how do we know which way the ball will spin after it hits a wall?

Solution:

We multiply the speed at which the ball travels and rotates by a factor of 1.414 to speed up the ball and a factor of 0.707 to slow down the ball. We will know which way the ball should spin after hitting a wall by checking for the direction that the ball was already currently spinning prior to touching a wall to give it a sensible rotation.