also some buttons added to be completed button class initalized Signed-off-by: SpagettiFisch <63868515+SpagettiFisch@users.noreply.github.com>
25 lines
No EOL
765 B
Python
25 lines
No EOL
765 B
Python
import pygame
|
|
|
|
font = pygame.font.SysFont('Arial', 40)
|
|
|
|
class Button():
|
|
def __init__(self, x, y, width, height, buttonText='Button', onclickFunction=None, onePress=False):
|
|
self.x = x
|
|
self.y = y
|
|
self.width = width
|
|
self.height = height
|
|
self.onclickFunction = onclickFunction
|
|
self.onePress = onePress
|
|
self.alreadyPressed = False
|
|
|
|
self.fillColors = {
|
|
'normal': '#ffffff',
|
|
'hover': '#666666',
|
|
'pressed': '#333333',
|
|
}
|
|
|
|
self.buttonSurface = pygame.Surface((self.width, self.height))
|
|
self.buttonRect = pygame.Rect(self.x, self.y, self.width, self.height)
|
|
|
|
self.buttonSurf = font.render(buttonText, True, (20, 20, 20))
|
|
return self |