Commit 4a58f121 by BellCodeEditor

save project

parent 9bd4c668
Showing with 13 additions and 2 deletions
......@@ -4,9 +4,9 @@ from pygame import locals
pygame.init() # 初始化
# 创建窗口
screen = pygame.display.set_mode((640, 480))
pygame.mixer.music.load("歌曲2.wav")
pygame.mixer.music.load("歌曲1.wav")
v=0.3
pygame.mixer.mu
pygame.mixer.music.set_volume(v)
# 载入图片、资源
bg_img = pygame.image.load('background.png') # 背景图
play_img = pygame.image.load('play.png') # 播放按钮
......@@ -19,6 +19,17 @@ 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:
v+=0.1
if v>1:
v=1
pygame.mixer.music.set_volume(v)
if event.key==locals.K_DOWN:
v-=0.1
if v<0:
v=0
pygame.mixer.music.set_volume(v)
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