Commit f7c84a9a by BellCodeEditor

save project

parent 90106ed3
Showing with 8 additions and 2 deletions
import pygame import pygame
import os
from pygame import locals from pygame import locals
pygame.init() # 初始化 pygame.init() # 初始化
...@@ -17,7 +18,12 @@ volume=0.5 ...@@ -17,7 +18,12 @@ volume=0.5
play_button=stop_img play_button=stop_img
click=0 click=0
num=-1 num=-1
music=['歌曲1.wav','歌曲2.wav','歌曲3.wav','歌曲4.ogg'] music=[]
path="C:\\Users\\lenovo\\Desktop\\test"
m=os.listdir(path)
for i in m:
if i[-4:]==".ogg" or i[-4:]=="wav":
music.append(i)
while True: while True:
for event in pygame.event.get(): for event in pygame.event.get():
if event.type==locals.QUIT: if event.type==locals.QUIT:
...@@ -48,7 +54,7 @@ while True: ...@@ -48,7 +54,7 @@ while True:
num=num+1 num=num+1
if num>len(music)-1: if num>len(music)-1:
num=0 num=0
pygame.mixer.music.load(music[num]) pygame.mixer.music.load(path+"\\"+music[num])
pygame.mixer.music.play() pygame.mixer.music.play()
......
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