Commit 8a4032fd by BellCodeEditor

save project

parent 7dddac0b
import pygame import pygame
from pygame import locals from pygame import locals
pygame.init() # 初始化 pygame.init() # 初始化
# 创建窗口 # 创建窗口
screen = pygame.display.set_mode((640, 480)) screen = pygame.display.set_mode((640, 480))
# 载入图片、资源 # 载入图片、资源
...@@ -12,6 +12,9 @@ last_img = pygame.image.load('last.png') # 上一曲按钮 ...@@ -12,6 +12,9 @@ last_img = pygame.image.load('last.png') # 上一曲按钮
next_img = pygame.image.load('next.png') # 下一曲按钮 next_img = pygame.image.load('next.png') # 下一曲按钮
logo_img = pygame.image.load('logo.png') # 中间logo logo_img = pygame.image.load('logo.png') # 中间logo
pygame.mixer.music.load('歌曲4.ogg') pygame.mixer.music.load('歌曲4.ogg')
pygame.mixer.music.load('歌曲3.wav')
pygame.mixer.music.load('歌曲2.wav')
pygame.mixer.music.load('歌曲1.wav')
# while True: # while True:
...@@ -20,7 +23,10 @@ pygame.mixer.music.load('歌曲4.ogg') ...@@ -20,7 +23,10 @@ pygame.mixer.music.load('歌曲4.ogg')
# exit() # exit()
volume = 0.2 volume = 0.2
# pygame.mixer.music.set_volume(volume) # pygame.mixer.music.set_volume(volume)
filelist=[while expression:
pass
else:
pass]
start = stop_img start = stop_img
click = 0 click = 0
while True: while True:
...@@ -40,21 +46,25 @@ while True: ...@@ -40,21 +46,25 @@ while True:
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
click += 1 if x>270 and x<370 and y>350 and y<450:
if click%2 == 0: click += 1
pygame.mixer.music.unpause() if click%2 == 0:
start = stop_img pygame.mixer.music.unpause()
else: start = stop_img
pygame.mixer.music.pause() else:
start = play_img pygame.mixer.music.pause()
start = play_img
# if volume <=0: if pygame.mixer.gat_busy()==False:
# volume = 0 num+=1
if pygame.mixer.music.get_busy() == False: if num>len(filelist)-1:
num=0
pygame.mixer.music.load(filelist[num])
pygame.mixer.music.play() pygame.mixer.music.play()
if volume <=0:
# volume = 0
if pygame.mixer.music.get_busy() == False:
pygame.mixer.music.play()
# 绘制画面 # 绘制画面
screen.blit(bg_img, (0, 0)) # 填充背景 screen.blit(bg_img, (0, 0)) # 填充背景
screen.blit(start, (270, 330)) # 暂停按钮 screen.blit(start, (270, 330)) # 暂停按钮
......
import os
files=os.listdir('C:\\Users\\HW\\Desktop\\test')
print(files)
\ 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