Commit c9599f5b by BellCodeEditor

save project

parent e7ba12d2
Showing with 10 additions and 2 deletions
import pygame import pygame
import os
from pygame import locals from pygame import locals
l=os.listdir('C:\\Users\\EDZ\\Desktop\\test')
print(l)
pygame.init() # 初始化 pygame.init() # 初始化
# 创建窗口 # 创建窗口
screen = pygame.display.set_mode((640, 480)) screen = pygame.display.set_mode((640, 480))
...@@ -19,8 +22,13 @@ volume = 0.2 ...@@ -19,8 +22,13 @@ 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
m=['歌曲1.wav','歌曲2.wav','歌曲3.wav','歌曲4.ogg']
m=[]
mun=-1 mun=-1
for i in range(len(l)):
if l[i][-4:]=='.wav' or l[i][-4:]=='.ogg':
m.append(l[i])
print(m)
while True: while True:
for event in pygame.event.get(): for event in pygame.event.get():
...@@ -59,7 +67,7 @@ while True: ...@@ -59,7 +67,7 @@ while True:
mun+=1 mun+=1
if mun>len(m)-1: if mun>len(m)-1:
mun=0 mun=0
pygame.mixer.music.load(m[mun]) # 载入音乐 pygame.mixer.music.load('C:\\Users\\EDZ\\Desktop\\test'+'\\'+m[mun]) # 载入音乐
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