Develop a Python program that uses the graphics package.
Practice decision statements
Practice writing functions, including Boolean functions
In an effort to meet the public’s concerns regarding safety, Joyride, an amusement park ride manufacturer, is considering creating a new type of bumper car. This ride will have two cars on the track and will allow a computer to control the movement of the cars, guaranteeing that the cars alter direction upon collision. Before production begins, financial backing and management support of the idea must be obtained. As the lead programmer for Joyride, you have been asked to create a graphical simulation of the system to be presented to the board.
In your simulation, you have decided to represent bumper cars as small circles in a window. Write a program, bumper.py, that creates two circles of different colors and chooses initial random directions for them to move. If either circle hits a wall, that circle should move away from the wall (in the opposite direction of the wall). If the circles collide, have both circles change total opposite direction.
Because the initial movement is random, it is possible that the circles will never collide. It is also possible for the circles to get “stuck” in a repeating pattern. Both situations are okay and need not be prevented.
A sample execution will be shown during lecture. You are welcome to stop by my office to see the demo at any time.
Make yours a modular solution. Consider implementing the following methods or something similar:
getRandom(moveAmount) returns a random number between –moveAmount and + moveAmount
didCollide(ball,ball2) returns Boolean based on the collision of the two balls
hitVertical(ball, win) returns True if ball hits a vertical wall, False otherwise
hitHorizontal(ball, win) returns True if ball hits a horizontal wall, False otherwise
randomColor() returns a random color
Upload bumper.py to your class OAKS account. Remember to Upload file and Submit assignment.
The policies given in policy.doc are in effect for this and all assignments. Do not forget to include your name and the Certification of Authenticity.