-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy path01GUI.py
More file actions
38 lines (27 loc) · 1 KB
/
Copy path01GUI.py
File metadata and controls
38 lines (27 loc) · 1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
import pygame
import sys
# 全局初始化
pygame.init()
# 设置窗口的分辨率和标题
resolution = width,height = 480,700 #设置窗口大小和标题
windowSurface = pygame.display.set_mode(resolution) #设置分辨率并得到全局的【绘图表面】
pygame.display.set_caption("飞机大战")#设置标题
#加载背景图,返回的表面可以用于绘制其它对象于其上
bgSurface = pygame.image.load("./images/background.png").convert()
# 创建时钟对象
clock = pygame.time.Clock()
if __name__ == '__main__':
# 开启消息循环
while True:
# 处理用户输入
for event in pygame.event.get():
# 处理退出事件
if event.type == pygame.QUIT:
pygame.quit()
sys.exit()
# 将背景图像绘制于窗口表面windowSurface
windowSurface.blit(bgSurface, (0, 0))
# 绘制结束,刷新界面
pygame.display.flip()
# 时钟停留一帧的时长
clock.tick(60)