Commit e1a24d5c by BellCodeEditor

save project

parent 533dbbfd
Showing with 9 additions and 8 deletions
......@@ -15,7 +15,7 @@ logo_img = pygame.image.load('logo.png') # 中间logo
music_list = []
path = 'C:\\Users\\admin\\Desktop\\音乐'
filelist = os.listdir('C:\\Users\\admin\\Desktop\\音乐')
filelist = os.listdir(path)
for i in filelist:
if i[-4:] == '.wav' or i[-4:] == '.mp3':
music_list.append(i)
......@@ -25,25 +25,26 @@ volume = 0.2
pygame.mixer.music.set_volume(volume)
click = 0
play_button = stop_img
while True:
for event in pygame.event.get():
if event.type == locals.QUIT:
exit()
if event.type == locals.KEYDOWN:
if event.key == locals.K_w:
if event.key == locals.K_UP:
volume += 0.1
if volume>1:
volume = 1
pygame.mixer.music.set_volume(volume)
if event.key == locals.K_s:
if event.key == locals.K_DOWN:
volume -= 0.1
if volume<0:
if volume < 0:
volume = 0
pygame.mixer.music.set_volume(volume)
if event.type == locals.MOUSEBUTTONDOWN:
if event.button ==1:
x,y = event.posw
if event.button == 1:
x,y = event.pos
if x > 270 and x < 370 and y > 350 and y < 450:
click += 1
if click % 2 == 0:
......@@ -56,10 +57,10 @@ while True:
num -= 1
if num < 0:
num = len(music_list) - 1
pygame.mixer.music.load(path+'\\'+music_list[num])
pygame.mixer.music.load(path+"\\"+music_list[num])
pygame.mixer.music.play()
click = 0
play_button = stop_img
click = 0
if pygame.mixer.music.get_busy() == False:
num += 1
......
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