Commit 7f22903f by BellCodeEditor

save project

parent f862ee32
Showing with 27 additions and 19 deletions
......@@ -5,6 +5,7 @@ import os
pygame.init() # 初始化
# 创建窗口
screen = pygame.display.set_mode((640, 480))
FPS = pygame.time.Clock()
# 载入图片、资源
bg_img = pygame.image.load('background.png') # 背景图
play_img = pygame.image.load('play.png') # 播放按钮
......@@ -17,6 +18,7 @@ music_list=[]
volume = 0.2
path="C:\\Users\\dell\\Desktop\\test"
filelist=os.listdir(path)
music_list = []
for i in filelist:
if i[-4:] ==".mp3" or i[-4:]==".ogg" or i[-4:]==".wav":
music_list.append(i)
......@@ -48,7 +50,7 @@ while True:
if event.type == locals.MOUSEBUTTONDOWN:
if event.button == 1:
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
if click % 2 == 0:
......@@ -57,22 +59,26 @@ while True:
else:
play_button = play_img
pygame.mixer.music.pause()
if x > 120 and x < 220 and y > 350 and y < 400:
num -= 1
if num < 0:
num=len(music_list) -1
pygame.mixer.music.load(path+"\\"+music_list[num])
pygame.mixer.music.play()
play_button=stop_img
click=0
if x > 420 and x < 520 and y > 350 and y < 400:
num += 1
if num > len(music_list)-1:
num=0
pygame.mixer.music.load(path+"\\"+music_list[num])
pygame.mixer.music.play()
play_button=stop_img
click=0
if x > 420 and x < 520 and y > 350 and y < 450:
pygame.mixer.music.stop()
play_bytton = stop_img
if click % 2 == 0:
click += 2
else:
click += 1
if x > 120 and x < 220 and y > 350 and y < 450:
num -= 1
if num < 0:
num = len(music_list) - 1
pygame.mixer.music.load(path+"\\"+music_list[num])
pygame.mixer.music.play()
play_button=stop_img
if click % 2 == 0:
click += 2
else:
click += 1
if pygame.mixer.music.get_busy() == False:
......@@ -81,10 +87,11 @@ while True:
num=0
pygame.mixer.music.load(path+"\\"+music_list[num])
pygame.mixer.music.play()
new_logo = pygame.transform.rotate(logo_img, angle)
new_logo = pygame.transform.rotate(logo_img, -angle)
newRect = new_logo.get_rect(center=(320, 200))
pos = (newRect[0], newRect[1])
angle += 1
if play_button == stop_img:
angle += 1
# 绘制画面
screen.blit(bg_img, (0, 0)) # 填充背景
screen.blit(play_button, (270, 330)) # 暂停按钮
......@@ -93,3 +100,4 @@ while True:
screen.blit(next_img, (420, 350)) # 下一曲
# 刷新画面
pygame.display.update()
FPS.tick(60)
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