(using Python Graphics library)
im trying to create a function that has a circle bouncing left to right on a window and when the circle is clicked on, it stops moving horizontally and begins moving up and down on the window.
Python Graphics Library
solution:
import turtle
wn =turtle.screen()
wn.title("bouncing circle")
wn.tracer(0)
circle=turtle.Turtle()
circle=speed(0)
circle.dy =0
circle.dx=2
while True:
circle.setx(circle.xcor()+ circle.dy)
circle.setx(circle.xcor()+ circle.dx)
if circle.xcor()>200:
circle.dx *= -1
if circle.xcor()>200:
circle.dx*= -1
if circle stops moving horizontally and begins moving up and down on the window,while clicked on the value of dy and dy or error in looping area.
Get Answers For Free
Most questions answered within 1 hours.