Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import pygame
- pygame.init()
- class Button:
- def __init__(self, x, y, image):
- self.width = image.get_width()
- self.height = image.get_height()
- self.image = image
- self.rect = self.image.get_rect()
- self.rect.topleft = (x, y)
- self.clicked = False
- def draw(self, win):
- win.blit(self.image, (self.rect.x, self.rect.y))
- action = False
- pos = pygame.mouse.get_pos()
- if self.rect.collidepoint(pos) and self.clicked == False:
- if pygame.mouse.get_pressed()[0] == 1:
- self.clicked = True
- action = True
- if pygame.mouse.get_pressed()[0] == 0:
- self.clicked = False
- action = False
- return action
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement