Question: I'm trying to create a Python program that animates a circle to move across the screen to a mouse click location and then after moving

I'm trying to create a Python program that animates a circle to move across the screen to a mouse click location and then after moving to five mouse clicks, a "click to exit" message appears. One additional click closes the window.

Currently my program creates the window and the circle. The circle moves when clicked but does not move in the correct y direction towards the click. After clicking a second time, the circle moves completely off the screen.

I made my program into to separate parts: a main function that creates the window and circle and a move function that manages the circles movement. My main function is set up correctly already to call the move function, so its definitely an issue in that part of my code.

I pasted my move function below:

def move(circle,win): # Get center from circle c = circle.getCenter() print(c) # Get point from user click point = win.getMouse() print(point) # Get X coordinate dx = point.getX()-c.getX() print(dx) # Get Y coordinate dy = point.getY()-c.getY() print(dy) # The circle stops moving when the x coordinate equals the x coordinate of point while c.getX() != point.getX() and c.getY() != point.getY(): circle.move(1,0) c=circle.getCenter() sleep(0.002)

I need help getting the circle to move to the correct mouse click location 5 times, displaying the text message, and closing the program after an additional click. The circle must continue to move smoothly to the click location each time.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!