Commit f9ed8bb4 by BellCodeEditor

save project

parent ee790e54
Showing with 9 additions and 3 deletions
import pygame import pygame
import os
from pygame import locals from pygame import locals
filelist=['baby.ogg','Home.ogg','A Girl with Flowers.ogg','Soul For You.ogg'] parth="C:\\Users\\xxx\\Documents\\pygame_lesson5_diy2"
filelist=os.listdir(parth)
music_z=[]
for w in filelist:
if w[-4:]=='.ogg':
music_z.append(w)
pygame.init() # 初始化 pygame.init() # 初始化
# 创建窗口 # 创建窗口
screen = pygame.display.set_mode((640, 480)) screen = pygame.display.set_mode((640, 480))
...@@ -55,9 +61,9 @@ while True: ...@@ -55,9 +61,9 @@ while True:
if pygame.mixer.music.get_busy() == False: if pygame.mixer.music.get_busy() == False:
num+=1 num+=1
if num>len(filelist)-1: if num>len(music_z)-1:
num=0 num=0
pygame.mixer.music.load(filelist[num]) pygame.mixer.music.load(parth+'\\'+music_z[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