Skip to content

Instantly share code, notes, and snippets.

import pygame
from constants import *
class Button:
def __init__(self, text, x, y, font_name='Arial', font_size=18, color=(255, 255, 255),
background_color=(0, 0, 255), hover_color=(0, 102, 255), padding=10):
self.font = pygame.font.SysFont(font_name, font_size)
self.text_surface = self.font.render(text, True, color)
self.padding = padding
self.set_background_color(background_color)