Commit cd435ddc by BellCodeEditor

save project

parent 5b413d9c
Showing with 13 additions and 5 deletions
import pygame import pygame
from pygame import locals from pygame import locals
import os import os
d=1
pygame.init() # 初始化 pygame.init() # 初始化
# 创建窗口 # 创建窗口
screen = pygame.display.set_mode((640, 480)) screen = pygame.display.set_mode((640, 480))
...@@ -20,13 +20,14 @@ filelist = os.listdir(path) ...@@ -20,13 +20,14 @@ filelist = os.listdir(path)
for i in filelist: for i in filelist:
if i[-4:] == ".mp3" or i[-4:] == ".wav": if i[-4:] == ".mp3" or i[-4:] == ".wav":
music_list.append(i) music_list.append(i)
x1=170
x2=60
num = -1 num = -1
volume = 0.2 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
an=0
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:
...@@ -52,9 +53,12 @@ while True: ...@@ -52,9 +53,12 @@ while True:
if click % 2 == 0: if click % 2 == 0:
play_button = stop_img play_button = stop_img
pygame.mixer.music.unpause() pygame.mixer.music.unpause()
d=1
else: else:
play_button = play_img play_button = play_img
pygame.mixer.music.pause() pygame.mixer.music.pause()
d=0
if x>120 and x<220 and y>350 and y<400: if x>120 and x<220 and y>350 and y<400:
num-=1 num-=1
if num<0: if num<0:
...@@ -78,11 +82,15 @@ while True: ...@@ -78,11 +82,15 @@ while True:
num = 0 num = 0
pygame.mixer.music.load(path + "\\"+music_list[num]) pygame.mixer.music.load(path + "\\"+music_list[num])
pygame.mixer.music.play() pygame.mixer.music.play()
if d==1:
newlogo=pygame.transform.rotate(logo_img,an)
newrect=newlogo.get_rect(center=(320,200))
an+=1
# 绘制画面 # 绘制画面
pos=(newrect[0],newrect[1])
screen.blit(bg_img, (0, 0)) # 填充背景 screen.blit(bg_img, (0, 0)) # 填充背景
screen.blit(play_button, (270, 330)) # 暂停按钮 screen.blit(play_button, (270, 330)) # 暂停按钮
screen.blit(logo_img, (170, 60)) # 中间logo图 screen.blit(newlogo,pos) # 中间logo图
screen.blit(last_img, (120, 350)) # 上一曲 screen.blit(last_img, (120, 350)) # 上一曲
screen.blit(next_img, (420, 350)) # 下一曲 screen.blit(next_img, (420, 350)) # 下一曲
# 刷新画面 # 刷新画面
......
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