Question: Modify Example 1.5 so that the turtle bounces against all four sides. Start the turtle moving at an angle. Hint: bounce in the x direction
Modify Example 1.5 so that the turtle bounces against all four sides. Start the turtle moving at an angle. Hint: bounce in the x direction by changing the heading to 180 -heading(); in the y direction, set it to -heading().

1 # bounce . P 2 # Bounce the turtle. 3 4 from turtle import :* def move (distance): 6 7 8 9 10 """Move forward, reversing direction at right side. """ forward(distance) if xcor 320: setheading(180) 12 def main): 13 14 15 16 17 18 19 20 maln() shape ("circle") penup() speed(0) for_in range(100): move (10) exitonclick() Example 1.5 Bouncing turtle
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
