
import pygame
FPS = 60 # 每秒更新游戏画面的频率
WIDTH = 500 # 窗口宽度
HEIGHT = 600 # 窗口高度
# 游戏初始化
pygame.init()
screen = pygame.display.set_mode((WIDTH, HEIGHT)) # 游戏窗口
pygame.display.set_caption("飞机大战") # 窗口标题
clock = pygame.time.Clock() # 设定时钟,为了控制游戏更新画面频率
running = True
# 主游戏循环
while running:
clock.tick(FPS) # FPS一秒更新几次画面
# 鼠标键盘实践监听,回传列表
for event in pygame.event.get():
if event.type == pygame.QUIT:
running = False
# 更新游戏
# 显示
screen.fill((54, 173, 35)) # RGB 红绿蓝(0-255)
pygame.display.update()
pygame.quit()