Commit 7ed53335 by BellCodeEditor

save project

parent b5e2b02d
File added
...@@ -5,7 +5,7 @@ pygame.init() # 初始化 ...@@ -5,7 +5,7 @@ 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('鸡.jpg') # 背景图
play_img = pygame.image.load('play.png') # 播放按钮 play_img = pygame.image.load('play.png') # 播放按钮
stop_img = pygame.image.load('stop.png') # 暂停按钮 stop_img = pygame.image.load('stop.png') # 暂停按钮
last_img = pygame.image.load('last.png') # 上一曲按钮 last_img = pygame.image.load('last.png') # 上一曲按钮
...@@ -13,12 +13,13 @@ next_img = pygame.image.load('next.png') # 下一曲按钮 ...@@ -13,12 +13,13 @@ 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('歌曲1.wav') # 载入音乐 music = ['电报机.wav','605.mp3','歌曲1.wav','歌曲2.wav','歌曲3.wav','歌曲4.ogg','鸡你太美.mp3']
volume = 0.2 volume = 0.2
pygame.mixer.music.set_volume(volume) # 初始播放音量 pygame.mixer.music.set_volume(volume) # 初始播放音量
click = 0 click = 0
play_button = stop_img play_button = stop_img
num = -1
while True: while True:
for event in pygame.event.get(): for event in pygame.event.get():
...@@ -41,7 +42,8 @@ while True: ...@@ -41,7 +42,8 @@ while True:
if event.type == locals.MOUSEBUTTONDOWN: if event.type == locals.MOUSEBUTTONDOWN:
if event.button == 1: if event.button == 1:
x,y = event.pos x,y = event.pos
if x > 270 and x <370 and y > 350 and y < 450: if x > 270 and x < 370 and y > 350 and y < 450:
# 次数增加 # 次数增加
click += 1 click += 1
if click % 2 == 0: if click % 2 == 0:
...@@ -52,6 +54,10 @@ while True: ...@@ -52,6 +54,10 @@ while True:
pygame.mixer.music.pause() pygame.mixer.music.pause()
if pygame.mixer.music.get_busy() == False: if pygame.mixer.music.get_busy() == False:
num += 1
if num > len(music)-1:
num = 0
pygame.mixer.music.load(music[num])
pygame.mixer.music.play() pygame.mixer.music.play()
# 绘制画面 # 绘制画面
...@@ -61,4 +67,4 @@ while True: ...@@ -61,4 +67,4 @@ while True:
screen.blit(last_img, (120, 350)) # 上一曲 screen.blit(last_img, (120, 350)) # 上一曲
screen.blit(next_img, (420, 350)) # 下一曲 screen.blit(next_img, (420, 350)) # 下一曲
# 刷新画面 # 刷新画面
pygame.display.update() pygame.display.update()
File added
File added
File added
File added
鸡.jpg

87.1 KB

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