Commit fa2b4edf by BellCodeEditor

save project

parent efcd4583
Showing with 32 additions and 1 deletions
......@@ -5,6 +5,7 @@ pygame.init() # 初始化
# 创建窗口
screen = pygame.display.set_mode((640, 480))
# 载入图片、资源
bg_img = pygame.image.load('background.png') # 背景图
play_img = pygame.image.load('play.png') # 播放按钮
stop_img = pygame.image.load('stop.png') # 暂停按钮
......@@ -24,6 +25,10 @@ for i in filelist:
if i[-4:] == ".wav" or i[-4:] == ".ogg":
music_list.append(i)
num=-1
angle=0
basic_font=pygame.font.Font("neuropol.ttf",18)
while True:
for event in pygame.event.get():
if event.type==locals.QUIT:
......@@ -52,6 +57,9 @@ while True:
num = len(music_list)-1
pygame.mixer.music.load(path+"\\"+music_list[num])
pygame.mixer.music.play()
music1=pygame.mixer.Sound(path+"\\"+music_list[num])
music_length=music1.get_length()
music_length=int(music_length)
click=0
play_button=stop_img
if x>420 and x<520 and y>350 and y<400:
......@@ -60,6 +68,9 @@ while True:
num = 0
pygame.mixer.music.load(path+"\\"+music_list[num])
pygame.mixer.music.play()
music1=pygame.mixer.Sound(path+"\\"+music_list[num])
music_length=music1.get_length()
music_length=int(music_length)
click=0
play_button=stop_img
if pygame.mixer.music.get_busy()==False:
......@@ -68,13 +79,33 @@ while True:
num=0
pygame.mixer.music.load(path+"\\"+music_list[num])
pygame.mixer.music.play()
music1=pygame.mixer.Sound(path+"\\"+music_list[num])
music_length=music1.get_length()
music_length=int(music_length)
play_time = pygame.mixer.music.get_pos()
play_time = int(play_time/1000)
play_m = play_time//60
play_s = play_time%60
info = str(play_m) + ":" + str(play_s)
music_m = music_length//60
music_s = music_length%60
info2 = str(music_m) + ":" + str(music_s)
new_logo=pygame.transform.rotate(logo_img,angle)
newRect=new_logo.get_rect(center=(320,200))
pos=(newRect[0],newRect[1])
if start== stop_img:
angle+=1
# 绘制画面
screen.blit(bg_img, (0, 0)) # 填充背景
screen.blit(start, (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)) # 下一曲
scoreSuef = basic_font.render(info,True,(255,255,255))
screen.blit(scoreSuef,(100,440))
scoreSuef2 = basic_font.render("/"+info2,True,(0,0,0))
screen.blit(scoreSuef2,(150,440))
# 刷新画面
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