MCPcopy Index your code
hub / github.com/geekcomputers/Python / is_click_on_button

Function is_click_on_button

Snake Game Using Turtle/main.py:120–126  ·  view source on GitHub ↗

Checks if a click (x, y) is within the bounds of a visible button.

(name, x, y)

Source from the content-addressed store, hash-verified

118 scoreboard.reset()
119
120def is_click_on_button(name, x, y):
121 """Checks if a click (x, y) is within the bounds of a visible button."""
122 if name in buttons and buttons[name]['visible']:
123 btn = buttons[name]
124 return (btn['x'] - btn['w']/2 < x < btn['x'] + btn['w']/2 and
125 btn['y'] - btn['h']/2 < y < btn['y'] + btn['h']/2)
126 return False
127
128def handle_click(x, y):
129 """Main click handler to delegate actions based on button clicks."""

Callers 1

handle_clickFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected