pygame 最小游戏框架
import sys import pygame pygame.init() # 初始化pygame size = (width, height) = (500,500) # 屏幕尺寸 screen = pygame.display.set_mode(size) # 创建屏幕对象 clock = pygame.time.Clock() # 创建游戏时钟 # 进入游戏循环 while True: # 设置刷新帧率 clock.tick(60) # 事件检测 for event in pygame.event.get(): if event.type == pygame.QUIT: # 退出事件 sys.exit() pygame.display.update() #刷新屏幕 screen.fill((0,0,0)) # 填充背景色 pygame.quit()