For this program, five turtles shaped like balls will randomly move within the window. Start with your
Fantastic news! We've Found the answer you've been seeking!
Question:
For this program, five turtles shaped like balls will randomly move within the window. Start with your previous Turtle Bounce solution and change as follows.
Write a program called balls_bounce.py.
- Name your file exactly balls_bounce.py
- Add the standard header: name, date, brief description
- Import the turtle and random modules.
- Set up a window 500 x 500.
- Apply a title, Balls Bounce, to your window.
- Create a function to create a turtle object. The function should return a turtle as follows:
- shaped like a circle (ball).
- positioned in the window.
- Colored red.
- pen should be up.
- a random direction, each turtle a new random direction.
- Use a loop to create a list of five balls (turtle objects). In each iteration call the function that creates the ball and then add the ball to a list.
- Use a while True loop to simulate animation.
- Within the while True loop, nest a loop that loops over the items (turtles) in the list
- Move the item (a turtle) forward 5 pixels per movement.
- Use the function written in turtle_bounce that:
- Checks to see if the turtle (ball) has passed the edge of the window.
- If so, moves it backward and changes its direction.
- Repeat for all items in the list
- Add line comments for each logical section of your code.
Upload only your balls_bounce.py to this assignment. A screenshot is not necessary.
Related Book For
Principles of Communications Systems, Modulation and Noise
ISBN: 978-8126556793
7th edition
Authors: Rodger E. Ziemer, William H. Tranter
Posted Date: