Commit f45793bf by BellCodeEditor

save project

parent 59397fff
...@@ -5,15 +5,15 @@ pygame.init() # 初始化 ...@@ -5,15 +5,15 @@ pygame.init() # 初始化
# 创建窗口 # 创建窗口
screen = pygame.display.set_mode((640, 480)) screen = pygame.display.set_mode((640, 480))
# 载入图片、资源 # 载入图片、资源
bg_img = pygame.image.load('background.png') # 背景图 bg_img = pygame.image.load('background.png')
play_img = pygame.image.load('play.png') # 播放按钮 play_img = pygame.image.load('play.png')
stop_img = pygame.image.load('stop.png') # 暂停按钮 stop_img = pygame.image.load('stop.png')
last_img = pygame.image.load('last.png') # 上一曲按钮 last_img = pygame.image.load('last.png')
next_img = pygame.image.load('next.png') # 下一曲按钮 next_img = pygame.image.load('next.png')
logo_img = pygame.image.load('logo.png') # 下一曲按钮 logo_img = pygame.image.load('logo.png')
# 载入音乐 # 载入音乐
pygame.mixer.music.load('歌曲1.wav') # 载入音乐 pygame.mixer.music.load('歌曲4.ogg') # 载入音乐
volume = 0.2 volume = 0.2
pygame.mixer.music.set_volume(volume) # 初始播放音量 pygame.mixer.music.set_volume(volume) # 初始播放音量
...@@ -27,12 +27,12 @@ while True: ...@@ -27,12 +27,12 @@ while True:
# 按键,控制声音大小 # 按键,控制声音大小
if event.type == locals.KEYDOWN: if event.type == locals.KEYDOWN:
if event.key == locals.K_UP: if event.key == locals.K_UP:
volume += 0.1 volume += 0.09
if volume > 1: if volume > 1:
volume = 1 volume = 1
pygame.mixer.music.set_volume(volume) pygame.mixer.music.set_volume(volume)
if event.key == locals.K_DOWN: if event.key == locals.K_DOWN:
volume -= 0.1 volume -= 0.07
if volume < 0: if volume < 0:
volume = 0 volume = 0
pygame.mixer.music.set_volume(volume) pygame.mixer.music.set_volume(volume)
......
File added
File added
File added
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