Commit 81031e0b by BellCodeEditor

save project

parent 1754f9f4
Showing with 18 additions and 7 deletions
...@@ -11,9 +11,8 @@ stop_img = pygame.image.load('stop.png') # 暂停按钮 ...@@ -11,9 +11,8 @@ 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') # 下一曲按钮
list1=['歌曲1.wav','歌曲2.wav','歌曲3.wav','歌曲4.ogg']
# 载入音乐 num=-1
pygame.mixer.music.load('歌曲4.ogg') # 载入音乐
volume = 0.2 volume = 0.2
pygame.mixer.music.set_volume(volume) # 初始播放音量 pygame.mixer.music.set_volume(volume) # 初始播放音量
...@@ -36,21 +35,33 @@ while True: ...@@ -36,21 +35,33 @@ while True:
if volume < 0: if volume < 0:
volume = 0 volume = 0
pygame.mixer.music.set_volume(volume) pygame.mixer.music.set_volume(volume)
# 按下鼠标 # 按下鼠标
if event.type == locals.MOUSEBUTTONDOWN: if event.type == locals.MOUSEBUTTONDOWN:
# 次数增加
click += 1 click += 1
x,y=event.pos
if event.button==1 :
if x>270 and x<370 and y>350 and y<450:
if click % 2 == 0: if click % 2 == 0:
play_button = stop_img play_button = stop_img
pygame.mixer.music.unpause() pygame.mixer.music.unpause()
else: else:
play_button = play_img play_button = play_img
pygame.mixer.music.pause() pygame.mixer.music.pause()
if x>120 and x<220 and y>350 and y<400:
num-=2
if num<0:
num=len(list1)-2
pygame.mixer.music.stop()
play_button=stop_img
if x>420 and x<520 and y>350 and y<400:
pygame.mixer.music.stop()
play_button=stop_img
if pygame.mixer.music.get_busy() == False: if pygame.mixer.music.get_busy() == False:
num+=1
if num>len(list1)-1:
num=0
pygame.mixer.music.load(list1[num]) # 载入音乐
pygame.mixer.music.play() pygame.mixer.music.play()
# 绘制画面 # 绘制画面
screen.blit(bg_img, (0, 0)) # 填充背景 screen.blit(bg_img, (0, 0)) # 填充背景
screen.blit(play_button, (270, 330)) # 暂停按钮 screen.blit(play_button, (270, 330)) # 暂停按钮
......
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