-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathButton.py
More file actions
33 lines (28 loc) · 1.12 KB
/
Button.py
File metadata and controls
33 lines (28 loc) · 1.12 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
from Rectangle import Rectangle
import pygame
""" Das geht ja nich das simon mehr commits hier hat als ich,
also änder ich jetz ganz viele Dateien
-The_Lie0
"""
class Button():
def __init__(self, game, position, label, function):
self.game = game
self.init(position, label, function)
def init(self, position, label, function):
self.function = function
self.position = position
self.background = Rectangle(self.game, position, [48,16], [32,32,32])
pygame.font.init()
self.font = pygame.font.Font('assets/fonts/Munro.ttf', 14)
self.textSurface = self.font.render(label, False, (255, 255, 255))
def update(self, deltaTime, events):
for event in events:
if event.type == pygame.MOUSEBUTTONDOWN and event.button == 1:
pos = self.game.cursor.get_pos()
if self.background.rect.collidepoint(pos):
self.function()
def draw(self, screen):
self.background.draw(screen)
screen.blit(self.textSurface, (self.position[0] + 2, self.position[1] + 1))
def destroy(self):
pass