You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

23 lines
754 B

6 months ago
import pygame
class Button:
"""生成图形的类"""
def __init__(self, screen, message):
self.screen = screen
self.message = message
self.screen_rect = self.screen.get_rect()
self.font = pygame.font.SysFont(None, 48)
self.font_color = (0, 70, 0)
self.image = self.font.render(self.message, True, self.font_color, None)
self.image_rect = self.image.get_rect()
self.image_rect.center = self.screen_rect.center
def place(self, x, y):
self.image_rect.x = x
self.image_rect.y = y
def display(self):
self.screen.blit(self.image, self.image_rect)