Commit 750de466 by BellCodeEditor

auto save

parent 401a3d38
Showing with 12 additions and 10 deletions
import pygame
from pygame import locals
import os
pygame.init() # 初始化
# 创建窗口
screen = pygame.display.set_mode((640, 480))
......@@ -11,12 +10,14 @@ play_img = pygame.image.load('play.png') # 播放按钮
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_img = pygame.image.load('logo.png')
music_list = []
path = "C:\\Users\\bellcode\\Desktop\\test"
path = "C:\\Users\\002\\Desktop\\新建文件夹"
filelist = os.listdir(path)
num = -1
abcd=1
xx=0
yy=0
for i in filelist:
if i[-4:] == ".wav" or i[-4:] == ".ogg":
music_list.append(i)
......@@ -24,7 +25,6 @@ volume = 0.2
pygame.mixer.music.set_volume(volume) # 初始播放音量
click = 0
play_button = stop_img
while True:
for event in pygame.event.get():
if event.type == locals.QUIT:
......@@ -41,7 +41,6 @@ while True:
if volume < 0:
volume = 0
pygame.mixer.music.set_volume(volume)
if event.type == locals.MOUSEBUTTONDOWN:
if event.button == 1: # 左击
x, y = event.pos
......@@ -64,7 +63,6 @@ while True:
click += 2
else:
click += 1
if x > 120 and x < 220 and y > 350 and y < 400: # 上一曲
num -= 1
if num < 0:
......@@ -76,19 +74,22 @@ while True:
click += 2
else:
click += 1
if pygame.mixer.music.get_busy() == False:
num += 1
if num > len(music_list)-1:
num = 0
pygame.mixer.music.load(path + "\\" + music_list[num])
pygame.mixer.music.play()
new_logo=pygame.transform.rotate(logo_img,abcd)
aaaaa=new_logo.get_rect(center=(320,200))
pos=(aaaaa[0],aaaaa[1])
abcd+=19999999999999999999999999999999
# 绘制画面
screen.blit(bg_img, (0, 0)) # 填充背景
screen.blit(play_button, (270, 330)) # 暂停按钮
screen.blit(logo_img, (170, 60)) # 中间logo图
screen.blit(last_img, (120, 350)) # 上一曲
screen.blit(next_img, (420, 350)) # 下一曲
screen.blit(new_logo, (pos))# 中间logo图
# 刷新画面
pygame.display.update()
#print(Surface.get_rect(center=(x,y))
\ 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