Edited code from the bouncing ball video.