


代码如下:
#导入pygame 和 初始化pygame相关接口 设置屏幕大小
import pygame
pygame.init()
screen=pygame.display.set_mode([1080,760])
#设置屏幕的背景颜色
screen.fill([255,255, 255])
pygame.display.update()
#设置屏幕的标题
pygame.display.set_caption(“羊羊传奇”)
#设置游戏窗口的小图标
#进入ICON的图标搜索网址 找到和程序相符的图标 或者自己喜欢的
#https://www.flaticon.com/
icon=pygame.image.load(‘fantasy.png’)
pygame.display.set_icon(icon)
#设置游戏循环 和 退出机制
#game 循环
running = True
while running:
for event in pygame.event.get():
if event.type == pygame.QUIT:
running=False
#screen.fill([255,255, 255])
#pygame.display.update()
pygame.quit()
源代码及资源下载:https://github.com/yiyinyiyang/pygamefly
参考视频:http://yangyanghub.com/2020/08/02/python-game-development-using-pygame-and-python-3/