Commit 03c14889 by BellCodeEditor

save project

parent 205bebb7
Showing with 57 additions and 9 deletions
i = 1
j=1
for j in range(1,10):
print(i,'*',j,'=',(i*j),end=" ")
import pygame
import pygame,os
from pygame import locals
pygame.init() # 初始化
......@@ -11,8 +11,17 @@ stop_img = pygame.image.load('stop.png') # 暂停按钮
last_img = pygame.image.load('last.png') # 上一曲按钮
next_img = pygame.image.load('next.png') # 下一曲按钮
logo_img = pygame.image.load('logo.png') # 中间logo
basic_font = pygame.font.Font('neuropol.ttf',14)
pygame.mixer.music.load('test.wav')
music_list = []
path = '.\\'
filelist = os.listdir(path)
for i in filelist:
if i[-4:] == '.ogg' or i[-4:] == '.wav':
music_list.append(i)
num = -1
angle = 0
vl = 0.8
pygame.mixer.music.set_volume(vl)
......@@ -36,24 +45,59 @@ while True:
pygame.mixer.music.set_volume(vl)
print(vl)
if event.type == locals.MOUSEBUTTONDOWN:
click += 1
if click % 2 == 0:
play_button = stop_img
pygame.mixer.music.unpause()
else:
play_button = play_img
pygame.mixer.music.pause()
if event.button == 1:
x,y = event.pos
if x>270 and x<370 and y>350 and y<450:
click += 1
if click % 2 == 0:
play_button = stop_img
pygame.mixer.music.unpause()
else:
play_button = play_img
pygame.mixer.music.pause()
if x>120 and x<220 and y>350 and y<400:
num -= 1
if num <0:
num = len(music_list)-1
pygame.mixer.music.load(path + '\\' + music_list[num])
pygame.mixer.music.play()
if x>420 and x<520 and y>350 and y<400:
num += 1
if num >len(music_list)-1:
num = 0
pygame.mixer.music.load(path + '\\' + music_list[num])
pygame.mixer.music.play()
if pygame.mixer.music.get_busy() == False:
num +=1
if num >len(filelist)-1:
num = 0
pygame.mixer.music.load(path + '\\' + music_list[num])
pygame.mixer.music.play()
play_time = pygame.mixer.music.get_pos()
# print(play_time)
play_time = int(play_time/1000)
play_m = play_time//60
play_s = play_time%60
info = str(play_m) + ':' + str(play_s)
new_logo = pygame.transform.rotate(logo_img,angle)
newRect = new_logo.get_rect(center =(320,200))
pos = (newRect[0],newRect[1])
if play_button == stop_img:
angle +=1
# 绘制画面
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)) # 下一曲
scoreSurf = basic_font.render(info,True,(255,255,255))
screen.blit(scoreSurf,(120,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