# button.py import pygame class Button: def __init__(self, x, y, image, scale): self.x = x self.y = y self.image = pygame.transform.scale(image, (image.get_width() * scale, image.get_height() * scale)) self.rect = self.image.get_rect() self.rect.topleft = (x, y) def draw(self, surface): surface.blit(self.image, (self.x, self.y)) action = False # Mouse position pos = pygame.mouse.get_pos() # Check if mouse is over the button and if the button is clicked if self.rect.collidepoint(pos): if pygame.mouse.get_pressed()[0] == 1: # Left mouse button clicked action = True return action