Commit ed0bb739 by BellCodeEditor

save project

parent 7bfc16a5
Showing with 15 additions and 5 deletions
...@@ -6,14 +6,16 @@ pygame.init() # 初始化 ...@@ -6,14 +6,16 @@ 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('stop.png') # 播放按钮
stop_img = pygame.image.load('stop.png') # 暂停按钮 stop_img = pygame.image.load('play.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 logo_img = pygame.image.load('logo.png') # 中间logo
pygame.mixer.music.load('歌曲4.ogg') pygame.mixer.music.load('歌曲1.wav')
volume=0.4 volume=0.4
k_mouse=0
play_button=play_img
while True: while True:
pygame.mixer.music.set_volume(volume) pygame.mixer.music.set_volume(volume)
...@@ -23,15 +25,23 @@ while True: ...@@ -23,15 +25,23 @@ while True:
elif event.type == pygame.KEYDOWN: elif event.type == pygame.KEYDOWN:
if (event.key == pygame.K_UP) or (event.key == pygame.K_w): if (event.key == pygame.K_UP) or (event.key == pygame.K_w):
volume+=0.2 volume+=0.2
elif (event.key == pygame.K_DOWN) or (event.key == pygame.K_s): elif (event.key == pygame.K_sDOWN) or (event.key == pygame.K_s):
if volume>=0.2: if volume>=0.2:
volume-=0.2 volume-=0.2
elif event.type == pygame.MOUSEBUTTONDOWN:
k_mouse+=1
if k_mouse % 2 == 1:
play_button=stop_img
pygame.mixer.music.pause()
else:
play_button=play_img
pygame.mixer.music.unpause()
print(volume) print(volume)
if not pygame.mixer.music.get_busy(): if not pygame.mixer.music.get_busy():
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