Computer Science 220 Bumper Cars Program

$25.00

Category: You will Instantly receive a download link for .zip solution file upon Payment || To Order Original Work Click Custom Order?

Description

5/5 - (4 votes)

Learning objectives:

  • Develop a Python program that uses the graphics package.
  • Practice decision statements
  • Practice writing functions, including Boolean functions

 

Assignment:

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:

 

  1.  getRandom(moveAmount) à returns a random number between –moveAmount and + moveAmount
  2. didCollide(ball,ball2) à returns Boolean based on the collision of the two balls
  3. hitVertical(ball, win) à returns True if ball hits a vertical wall, False otherwise
  4. hitHorizontal(ball, win) à returns True if ball hits a horizontal wall, False otherwise
  5. randomColor() à returns a random color

 

Submission:

Upload bumper.py to your class OAKS account. Remember to Upload file and Submit assignment.

 

Policies:

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.