Commit d59c888a by BellCodeEditor

save project

parent d1684d9f
Showing with 30 additions and 11 deletions
import pygame import pygame
from pygame import locals from pygame import locals
import os import os
angle = 0
p = 0
pygame.init() pygame.init()
screen = pygame.display.set_mode((640, 480)) screen = pygame.display.set_mode((640, 480))
bg_img = pygame.image.load('background.png') bg_img = pygame.image.load('background.png')
...@@ -10,6 +11,7 @@ stop_img = pygame.image.load('stop.png') ...@@ -10,6 +11,7 @@ stop_img = pygame.image.load('stop.png')
last_img = pygame.image.load('last.png') last_img = pygame.image.load('last.png')
next_img = pygame.image.load('next.png') next_img = pygame.image.load('next.png')
logo_img = pygame.image.load('logo.png') logo_img = pygame.image.load('logo.png')
font = pygame.font.Font("neuropol.ttf",18)
volume=0.2 volume=0.2
pygame.mixer.music.set_volume(volume) pygame.mixer.music.set_volume(volume)
click=0 click=0
...@@ -50,9 +52,11 @@ while True: ...@@ -50,9 +52,11 @@ while True:
if click%2==0: if click%2==0:
pygame.mixer.music.unpause() pygame.mixer.music.unpause()
play_button=stop_img play_button=stop_img
p = 0
else: else:
pygame.mixer.music.pause() pygame.mixer.music.pause()
play_button=play_img play_button=play_img
p = 1
if x > 120 and x <220 and y > 350 and y < 450: if x > 120 and x <220 and y > 350 and y < 450:
num -= 1 num -= 1
if num < 0: if num < 0:
...@@ -61,19 +65,33 @@ while True: ...@@ -61,19 +65,33 @@ while True:
pygame.mixer.music.play() pygame.mixer.music.play()
click = 0 click = 0
play_button = stop_img play_button = stop_img
if x > 420 and x < 520 and y > 350 and y < 450: if x > 420 and x < 520 and y > 350 and y < 450:
num += 1 num += 1
if num > len(music_list)-1: if num > len(music_list)-1:
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()
click = 0 click = 0
play_button = stop_img play_button = stop_img
# 绘制画面 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 = font.render(info,True,(0,0,0))
# 绘制画面
new_logo = pygame.transform.rotate(logo_img,angle)
newRect = new_logo.get_rect(center = (320,200))
pos = (newRect[0],newRect[1])
if p == 0:
angle += 0.5
else:
angle += 0
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)) screen.blit(new_logo,pos)
screen.blit(last_img, (120, 350)) screen.blit(last_img, (120, 350))
screen.blit(text,(120,440))
screen.blit(next_img, (420, 350)) screen.blit(next_img, (420, 350))
# 刷新画面 # 刷新画面
pygame.display.update() pygame.display.update()
\ 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