import pygame
import sys
from pygame.display import set_caption
class Al_games:
def __init__(self) -> None:
pygame.init() # 初始化pygame模块
self.screen = pygame.display.set_mode((1200, 800)) # 设置窗口大小
pygame.display.set_caption("abc") # 设置窗口标题
self.bg_color = (100, 100, 100) # 设置窗口背景颜色
def run_game(self):
while True:
# 监听键盘事件
for every in pygame.event.get():
if every.type == pygame.QUIT:
sys.exit()
self.screen.fill(self.bg_color) # 设置背景颜色
pygame.display.flip() # 显示窗口
if __name__ == '__main__':
a = Al_games()
a.run_game()