Commit 024e8b3b by BellCodeEditor

auto save

parent 9a0ec4ce
Showing with 32 additions and 4 deletions
......@@ -11,15 +11,43 @@ stop_img = pygame.image.load('stop.png') # 暂停按钮
last_img = pygame.image.load('last.png') # 上一曲按钮
next_img = pygame.image.load('next.png') # 下一曲按钮
logo_img = pygame.image.load('logo.png') # 中间logo
pygame.mixer.music.load('歌曲4.ogg') # 载入音乐
while True: # 循环
for event in pygame.event.get():
if event.type == locals.QUIT:
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循环
for event in pygame.event.get(): # 遍历列表中的事件
if event.type == locals.QUIT: # if判断事件类型编号与lcals模块的QUIT事件编号是否相等
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 # 变量click值增加1
if click % 2 == 0: # 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: # 音乐是否正在播放
pygame.mixer.music.play() # 播放音乐
# 绘制画面
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(last_img, (120, 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