I am working on a project within Python that is to determine the multi-tasking efficiency of a person. Part of the project is to have a user respond to an event on screen using the mouse. I have decided to have the user click within a ball. However I am having issues with my code on verifying that the mouse cursor is actually within the confines of the circle.
The code for the methods in question are below. Radius of the circle is 10.
#boolean method to determine if the cursor is within the position of the circle
@classmethod
def is_valid_mouse_click_position(cls, the_ball, mouse_position):
return (mouse_position) == ((range((the_ball.x - 10),(the_ball.x + 10)),
range((the_ball.y + 10), (the_ball.y - 10))))
#method called when a pygame.event.MOUSEBUTTONDOWN is detected.
def handle_mouse_click(self):
print (Ball.is_valid_mouse_click_position(self.the_ball,pygame.mouse.get_pos))
No matter where I click within the circle, the boolean still returns False.