From: Skullheadx Date: Tue, 25 Apr 2023 23:43:46 +0000 (-0400) Subject: button fix X-Git-Url: http://git.skullheadx.com/nixos/blog/static/gitweb.css?a=commitdiff_plain;h=b4537879514d5c2c502a8492ea30d57eab252a22;p=Snake.git button fix --- diff --git a/button.py b/button.py index f45fb82..fd02a6a 100644 --- a/button.py +++ b/button.py @@ -28,5 +28,5 @@ class Button(Label): def get_input(self, event): if event.type == pygame.MOUSEBUTTONUP: - if event.button == 1: # Left Mouse Button + if event.button == 1 and self.get_rect().collidepoint(pygame.mouse.get_pos()): # Left Mouse Button self.activated = True diff --git a/setup.py b/setup.py index da063b1..0d7b10e 100644 --- a/setup.py +++ b/setup.py @@ -2,7 +2,7 @@ import pygame pygame.init() -LENGTH, HEIGHT = 20,20 +LENGTH, HEIGHT = 20, 20 side_length = 640 / LENGTH x_unit = pygame.Vector2(side_length, 0) y_unit = pygame.Vector2(0, side_length)