Question: Checkpoint 2 Bouncing off the Walls Now things will get interesting. Instead of your ball disappearing from one end of the canvas, what if the

 Checkpoint 2 Bouncing off the Walls Now things will get interesting.

Checkpoint 2 Bouncing off the Walls Now things will get interesting. Instead of your ball disappearing from one end of the canvas, what if the ball just bounced when it hit the edge of the canvas and started moving in a different direction? In particular if it hits the left (x==0) or right (x==maxx) wall, it should negate its dx value, while if it hits the top (y== ) or bottom (y==maxy) wall, it should negate its dy value. Be sure to account for the ball radius when doing your calculations. The ball should bounce when the edge of the ball contacts the wall. This creates the effect of a bouncing ball with no friction and no spin. Accomplish this in a new method of the Ball class called check_and_reverse which should have two arguments: maxx and maxy. COPy check1.py into check2.py. In the new le, you will need to call this function from the main code each time you move the ball. Add text in test_Ba11 .py to test check_and_reverse

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!