pygame简介
- Pygame is a set of Python modules designed for writing video games.
- Pygame adds functionality on top of the excellent SDL library.
- This allows you to create fully featured games and multimedia programs in the python language.
- pygame适用于游戏逻辑验证,游戏入门及系统演示验证;
pygame的最小开发框架
总共包含:引入、初始化、获取时间并逐类响应、刷新屏幕
import pygame # step1:引入pygame模块 pygame.init() # step2:初始化pygame的模块 screen = pygame.display.set_mode((400, 400)) # step2:初始化窗体<一个游戏有且仅有一个> pygame.display.set_caption("pygame最小开发架构") # step2:设置这个基本窗体的标题 icon = pygame.image.load('player.png') # step2:初始化一些资源文件,音频视屏图片之类,返回surface对象 while True: # step3及step4是循环处理的 for event in pygame.event.get(): # step3 轮询事件队列,并逐个给予处理 if event.type == pygame.QUIT: # step3 对事件进行响应 quit() pygame.display.update() #step4 刷新基本窗体,将变化体现在基本窗体上
初始化
end