import pygame

初始化pygame

pygame.init()

定义窗口大小

screen_width = 600 screen_height = 400

定义窗口名

game_name = "game"

创建窗口

screen = pygame.display.set_mode((screen_width, screen_height)) pygame.display.set_caption(game_name)

游戏主循环

running = True while running: for event in pygame.event.get(): if event.type == pygame.QUIT: running = False

# 渲染窗口
screen.fill((0, 0, 0))
pygame.display.flip()

退出游戏

pygame.quit()


原文地址: http://www.cveoy.top/t/topic/h0TL 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录