Commit 2b64d9b7 by BellCodeEditor

save project

parent 28e22d30
Showing with 23 additions and 25 deletions
......@@ -12,8 +12,7 @@ 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') # 下一曲按钮
my_font = pygame.font.Font('neuropol.ttf') # 创建字体
my_font = pygame.font.Font('neuropol.ttf',15)
music_list = []
path = "C:\\Users\\Administrator\\Desktop\\test"
filelist = os.listdir(path)
......@@ -28,7 +27,6 @@ play_button = stop_img
angle = 0
FPSCLOCK = pygame.time.Clock()
while True:
if click % 2 == 0:
angle += 1
new_logo = pygame.transform.rotate(logo_img,angle)
......@@ -36,24 +34,26 @@ while True:
if event.type == locals.QUIT:
exit()
# 按键,控制声音大小
if event.type == locals.KEYDOWN:
if event.key == locals.K_w:
volume += 0.1
if volume > 1:
volume = 1
pygame.mixer.music.set_volume(volume)
if event.key == locals.K_s:
volume -= 0.1
if volume < 0:
volume = 0
pygame.mixer.music.set_volume(volume)
play_time = pygame.mixer.music.get_pos()
play_time = int(play_time/100)
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)
text = my_font.render(info, True, (0, 0, 0))
if event.type == locals.KEYDOWN:
if event.key == locals.K_w:
volume += 0.1
if volume > 1:
volume = 1
pygame.mixer.music.set_volume(volume)
if event.key == locals.K_s:
volume -= 0.1
if volume < 0:
volume = 0
pygame.mixer.music.set_volume(volume)
play_m = play_time // 60
play_s = play_time % 60
info = str(play_m) + ":" + str(play_m)
if event.type == locals.MOUSEBUTTONDOWN:
if event.button == 1: # 左击
x, y = event.pos
......@@ -88,7 +88,7 @@ while True:
click += 2
else:
click += 1
text = my_font.render(info, True,(0, 0, 0))
if pygame.mixer.music.get_busy() == False:
num += 1
if num > len(music_list)-1:
......@@ -99,15 +99,14 @@ while True:
# 绘制画面
newRect = new_logo.get_rect(center=(320,200))
pos = (newRect[0],newRect[1])
my_font.render(render, True, 0)
screen.blit(bg_img, (0, 0)) # 填充背景
screen.blit(play_button, (270, 330)) # 暂停按钮
screen.blit(new_logo, (pos)) # 中间logo图
screen.blit(last_img, (120, 350)) # 上一曲
screen.blit(next_img, (420, 350)) # 下一曲
screen.blit(info,(120,200))
screen.blit(next_img, (420, 350)) # 下一曲
screen.blit(text, (100, 450)) # 下一曲
# 刷新画面
pygame.display.update()
#调整帧数
FPSCLOCK.tick(60)
\ 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