Commit 362d427f by BellCodeEditor

auto save

parent 5db29307
Showing with 40 additions and 7 deletions
import pygame import pygame
from pygame import locals from pygame import locals
import os
pygame.init() # 初始化 pygame.init() # 初始化
# 创建窗口 # 创建窗口
...@@ -13,13 +14,19 @@ next_img = pygame.image.load('next.png') # 下一曲按钮 ...@@ -13,13 +14,19 @@ next_img = pygame.image.load('next.png') # 下一曲按钮
logo_img = pygame.image.load('logo.png') # 下一曲按钮 logo_img = pygame.image.load('logo.png') # 下一曲按钮
# 载入音乐 # 载入音乐
path = r"C:\Users\86186\Desktop\test"
music_list = ['歌曲1.wav','歌曲2.wav','歌曲3.wav','歌曲4.ogg'] # 载入音乐 music_list = os.listdir(path) # 载入音乐
music_real =[]
for n in music_list:
if n[-4:] == ".wav" or n[-4:] == ".ogg":
music_real.append(n)
print(music_real)
volume = 0.2 volume = 0.2
pygame.mixer.music.set_volume(volume) # 初始播放音量 pygame.mixer.music.set_volume(volume) # 初始播放音量
click = 0 click = 0
i = -1 i = 0
angle = 0
play_button = stop_img play_button = stop_img
while True: while True:
...@@ -52,18 +59,44 @@ while True: ...@@ -52,18 +59,44 @@ while True:
else: else:
play_button = play_img play_button = play_img
pygame.mixer.music.pause() pygame.mixer.music.pause()
if x >120 and x < 220 and y >350 and y <400:
i -= 1
if i <0:
i = len(music_real) - 1
pygame.mixer.music.load(path + "//" +music_real[i])
pygame.mixer.music.play()
click = 0
play_button = stop_img
if x >420 and x < 520 and y >350 and y <400:
i += 1
if i >len(music_real)-1:
i = 0
pygame.mixer.music.load(path + "//" +music_real[i])
pygame.mixer.music.play()
click = 0
play_button = stop_img
if pygame.mixer.music.get_busy() == False: if pygame.mixer.music.get_busy() == False:
i += 1
if i> len(music_list) - 1: if i> len(music_list) :
i = 0 i = 0
pygame.mixer.music.load(music_list[i]) pygame.mixer.music.load(path + "//" +music_real[i])
pygame.mixer.music.play() pygame.mixer.music.play()
i += 1
new_logo =pygame.transform.rotate(logo_img,angle)
new_rect =new_logo.get_rect(center = (320,200))
if play_button == stop_img:
angle += 1
pos = new_rect[0], new_rect[1]
# 绘制画面 # 绘制画面
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)) # 中间logo图 screen.blit(new_logo, (pos)) # 中间logo图
screen.blit(last_img, (120, 350)) # 上一曲 screen.blit(last_img, (120, 350)) # 上一曲
screen.blit(next_img, (420, 350)) # 下一曲 screen.blit(next_img, (420, 350)) # 下一曲
# 刷新画面 # 刷新画面
......
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