Commit 775b560b by BellCodeEditor

auto save

parent 19f22638
Showing with 7 additions and 1 deletions
......@@ -4,6 +4,7 @@ from pygame import locals
pygame.init() # 初始化
# 创建窗口
screen = pygame.display.set_mode((640, 480))
# 载入图片、资源
bg_img = pygame.image.load('background.png') # 背景图
play_img = pygame.image.load('play.png') # 播放按钮
......@@ -24,7 +25,7 @@ while True:
for event in pygame.event.get():
if event.type == locals.QUIT:
exit()
# 按键,控制声音大小
if event.type == locals.KEYDOWN:
if event.key == locals.K_UP:
volume += 0.1
......@@ -37,7 +38,11 @@ while True:
volume = 0
pygame.mixer.music.set_volume(volume)
if event.type == locals.MOUSEBUTTONDOWN:
if event.button == 1:
x, y = event.pos
if x > 270 and x < 370 and y > 350 y< 450
click += 1
if click % 2 == 0:
play_button = stop_img
......@@ -47,6 +52,7 @@ while True:
pygame.mixer.music.pause()
if pygame.mixer.music.get_busy() == False:
pygame.mixer.music.play()
# 绘制画面
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment