Commit dd6209d8 by BellCodeEditor

save project

parent 26b1eecf
Showing with 8 additions and 11 deletions
...@@ -21,7 +21,7 @@ click = 0 ...@@ -21,7 +21,7 @@ click = 0
play_button = stop_img play_button = stop_img
path="C:\\Users\\003\\Desktop\\test" path="C:\\Users\\003\\Desktop\\test"
filelist=os.listdir(path) filelist=os.listdir(path)
for m in filelist: for m in filelist:#插入音乐
if (m[-4:] == ".wav") or (m[-4:] == ".ogg"): if (m[-4:] == ".wav") or (m[-4:] == ".ogg"):
music_list.append(m) music_list.append(m)
while True: while True:
...@@ -41,9 +41,9 @@ while True: ...@@ -41,9 +41,9 @@ while True:
volume = 0 volume = 0
pygame.mixer.music.set_volume(volume) pygame.mixer.music.set_volume(volume)
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:
play_button = stop_img play_button = stop_img
...@@ -60,7 +60,7 @@ while True: ...@@ -60,7 +60,7 @@ while True:
play_button = stop_img play_button = stop_img
pygame.mixer.music.unpause() pygame.mixer.music.unpause()
click=0 click=0
if x>420 and x<520 and y >350 and y<400:# 一首 if x>420 and x<520 and y >350 and y<400:# 一首
number+=1 number+=1
if number>len(music_list)-1: if number>len(music_list)-1:
number=0 number=0
...@@ -69,18 +69,15 @@ while True: ...@@ -69,18 +69,15 @@ while True:
play_button = stop_img play_button = stop_img
pygame.mixer.music.unpause() pygame.mixer.music.unpause()
click=0 click=0
if pygame.mixer.music.get_busy() == False: if pygame.mixer.music.get_busy() == False:# 循环播放
number+=1 number+=1
if number>len(music_list)-1: if number>len(music_list)-1:
number=0 number=0
pygame.mixer.music.load(music_list[number]) pygame.mixer.music.load(music_list[number])
pygame.mixer.music.play() pygame.mixer.music.play()# 绘制画面
# 绘制画面
screen.blit(bg_img, (0, 0)) # 填充背景 screen.blit(bg_img, (0, 0)) # 填充背景
screen.blit(play_button, (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)) # 下一曲
# 刷新画面 pygame.display.update()# 刷新画面
pygame.display.update() \ No newline at end of file
\ No newline at end of file
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