Checks if a click (x, y) is within the bounds of a visible button.
(name, x, y)
| 118 | scoreboard.reset() |
| 119 | |
| 120 | def 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 | |
| 128 | def handle_click(x, y): |
| 129 | """Main click handler to delegate actions based on button clicks.""" |