Commit b2548c51 by BellCodeEditor

auto save

parent 998e5b8d
Showing with 21 additions and 19 deletions
...@@ -11,39 +11,41 @@ stop_img = pygame.image.load('stop.png') # 暂停按钮 ...@@ -11,39 +11,41 @@ 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('歌曲4.ogg')#导入音乐文件 pygame.mixer.music.load('歌曲3.wav') #导入音乐
volume=0.5
pygame.mixer.music.set_volume(volume) volume=0.5 #控制音量大小的变量
click=0 #统计次数 pygame.mixer.music.set_volume(volume) #设置音量大小
play_button=stop_img
click=0 #统计按下鼠标次数
button=stop_img #按钮形状
while True: while True:
for event in pygame.event.get():#使用event遍历pygame中发生的事件 pygame.mixer.music.set_volume(volume) #设置音量大小
if event.type==locals.QUIT: #如果事件是退出事件 for event in pygame.event.get():
exit()#那么就退出程序 if event.type == locals.QUIT:
#按下按键事件 exit() #退出程序
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.1
if volume>1: if volume >1:
volume=1 volume=1
if event.key==locals.K_DOWN: if event.key ==locals.K_DOWN:
volume-=0.1 volume-=0.1
if volume<=0: if volume<0:
volume=0 volume=0
if event.type==locals.MOUSEBUTTONDOWN: if event.type == locals.MOUSEBUTTONDOWN:
click+=1 click+=1
if click%2==0: if click%2==0:
play_button=stop_img button=stop_img
pygame.mixer.music.unpause() pygame.mixer.music.unpause()
else: else:
play_button=play_img button=play_img
pygame.mixer.music.pause() pygame.mixer.music.pause()
pygame.mixer.music.set_volume(volume) if pygame.mixer.music.get_busy()==False: #判断音乐是否播放
if pygame.mixer.music.get_busy()==False:
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(button, (270, 330)) # 暂停按钮
screen.blit(logo_img, (170, 60)) # 中间logo图 screen.blit(logo_img, (170, 60)) # 中间logo图
screen.blit(last_img, (120, 350)) # 上一曲 screen.blit(last_img, (120, 350)) # 上一曲
screen.blit(next_img, (420, 350)) # 下一曲 screen.blit(next_img, (420, 350)) # 下一曲
......
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