Commit e1faa705 by BellCodeEditor

auto save

parent 094b04de
Showing with 26 additions and 1 deletions
...@@ -13,16 +13,41 @@ next_img = pygame.image.load('next.png') # 下一曲按钮 ...@@ -13,16 +13,41 @@ next_img = pygame.image.load('next.png') # 下一曲按钮
logo_img = pygame.image.load('logo.png') # 中间logo logo_img = pygame.image.load('logo.png') # 中间logo
pygame.mixer.music.load('歌曲1.wav') # 载入音乐 pygame.mixer.music.load('歌曲1.wav') # 载入音乐
volume = 0.8 # 新建变量volume初始值设为0.8
pygame.mixer.music.set_volume(volume) # 初始播放音量
click = 0 # 新建变量click初始值设为0
play_button = stop_img # 创建变量play_button表示播放按钮造型并初始值设为stop_img暂停造型
while True: while True:
for event in pygame.event.get(): for event in pygame.event.get():
if event.type == locals.QUIT: # if判断事件类型编号与locals模块的QUIT事件编号是否相等 if event.type == locals.QUIT: # if判断事件类型编号与locals模块的QUIT事件编号是否相等
exit() # 接收到退出事件后退出程序 exit() # 接收到退出事件后退出程序
# 按键,控制声音大小
if event.type == locals.KEYDOWN: # if判断键盘是否按下
if event.key == locals.K_w: # if判断w键是否按下
volume += 0.1 # 音量增加0.1
if volume > 1: # if判断音量大于1
volume = 1 # 音量设为1
pygame.mixer.music.set_volume(volume) # 初始播放音量
if event.key == locals.K_s: # if判断s键是否按下
volume -= 0.1 # 音量减少0.1
if volume < 0: # if判断音量少于0
volume = 0 # 音量设为0
pygame.mixer.music.set_volume(volume) # 初始播放音量
if event.type == locals.MOUSEBUTTONDOWN:
click += 1
if click % 2 == 0:
play_button = stop_img
pygame.mixer.music.unpause()
else:
play_button = play_img
pygame.mixer.music.pause()
if pygame.mixer.music.get_busy() == False: # if判断音乐是否正在播放 if pygame.mixer.music.get_busy() == False: # if判断音乐是否正在播放
pygame.mixer.music.play() # 播放音乐 pygame.mixer.music.play() # 播放音乐
# 绘制画面 # 绘制画面
screen.blit(bg_img, (0, 0)) # 填充背景 screen.blit(bg_img, (0, 0)) # 填充背景
screen.blit(stop_img, (270, 330)) # 暂停按钮 screen.blit(play_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