Answered step by step
Verified Expert Solution
Question
1 Approved Answer
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. 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
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started