]> Skullheadx's Git Forge - Snake.git/commitdiff
button fix
authorSkullheadx <admonty1@gmail.com>
Tue, 25 Apr 2023 23:43:46 +0000 (19:43 -0400)
committerSkullheadx <admonty1@gmail.com>
Tue, 25 Apr 2023 23:43:46 +0000 (19:43 -0400)
button.py
setup.py

index f45fb828fd547a07ae07adf7d4d26304d550f9d7..fd02a6aafd0aee1df05bceaa207e892124a3892b 100644 (file)
--- 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
index da063b1cd75648d676d80a959b17619e28f7751b..0d7b10e15619072e344c3b1b11355d1c1bbd0cfd 100644 (file)
--- 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)