Commit 37d3a4ee by BellCodeEditor

save project

parent f60bf5c8
Showing with 24 additions and 4 deletions
import pygame
from pygame import locals
import os
angle=0
pygame.init() # 初始化
# 创建窗口
screen = pygame.display.set_mode((640, 480))
......@@ -18,8 +19,10 @@ lb=[]
aaa="C:\\Users\\4\\Desktop\\test"
bbb=os.listdir(aaa)
for i in bbb:
if bbb[-4:]==".wav" or bbb[-4:]==".ogg":
if i[-4:]==".wav" or i[-4:]==".ogg":
lb.append(i)
print(lb)
volume = 0.2
pygame.mixer.music.set_volume(volume) # 初始播放音量
click = 0
......@@ -53,17 +56,34 @@ while True:
else:
play_button = play_img
pygame.mixer.music.pause()
if x > 120 and y < 220 and x < 420 and y < 520:
num -=1
if num < 0:
num =len(music_list)-1
pygame.mixer.music.load(aaa+"\\"+music_list(num))
pygame.mixer.music.play()
if click % 2 == 0:
click += 1
if pygame.mixer.music.get_busy()== False:
num+=1
num =len(music_list)-1
pygame.mixer.music.load(aaa+"\\"+music_list(num))
pygame.mixer.music.play()
num =0
new_logo=pygame.transform.rotate(logo_img,angle)
newRect =new_logo.get_rect(center=(320,200))
pos =(newRect[0],newRect[1])
angle+=1
if pygame.mixer.music.get_busy() == False:
num+=1
if num >len(lb)+1:
if num >len(bbb)-1:
num=0
pygame.mixer.music.load(aaa+"\\"+lb[num])
pygame.mixer.music.play()
# 绘制画面
screen.blit(bg_img, (0, 0)) # 填充背景
screen.blit(play_button, (270, 330)) # 暂停按钮
screen.blit(logo_img, (170, 60)) # 中间logo图
screen.blit(new_logo, (pos)) # 中间logo图
screen.blit(last_img, (120, 350)) # 上一曲
screen.blit(next_img, (420, 350)) # 下一曲
# 刷新画面
pygame.display.update()
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