Commit 813758e0 by BellCodeEditor

auto save

parent 9298a7b6
File deleted
j.jpg

50.8 KB

import pygame import pygame
from pygame import locals import os
from pygame import locals
pygame.init() # 初始化 wq=r'C:\Users\Administrator\Desktop\test'
# 创建窗口 d=os.listdir(wq)
screen = pygame.display.set_mode((640, 480)) print(d)
# 载入图片、资源 pygame.init() # 初始化
bg_img = pygame.image.load('background.png') # 背景图 # 创建窗口
play_img = pygame.image.load('play.png') # 播放按钮 screen = pygame.display.set_mode((720, 720))
stop_img = pygame.image.load('stop.png') # 暂停按钮 # 载入图片、资源
last_img = pygame.image.load('last.png') # 上一曲按钮 bg_img = pygame.image.load('j.jpg') # 背景图
next_img = pygame.image.load('next.png') # 下一曲按钮 play_img = pygame.image.load('play.png') # 播放按钮
logo_img = pygame.image.load('logo.png') # 中间logo stop_img = pygame.image.load('stop.png') # 暂停按钮
pygame.mixer.music.load('605.mp3') last_img = pygame.image.load('last.png') # 上一曲按钮
v=0.1 next_img = pygame.image.load('next.png') # 下一曲按钮
pygame.mixer.music.set_volume(v) v=1
while True: c=0
num=-1
music=[]
for i in d:
if i[-4:]=='.wav':
music.append(i)
pygame.mixer.music.set_volume(v)
f=stop_img
while True:
for event in pygame.event.get(): for event in pygame.event.get():
if event.type==locals.MOUSEBUTTONDOWN:
if event.button==1:
x,y=event.pos
if x>270 and x<370 and y>350 and y<450:
c+=1
if c%2==0:
pygame.mixer.music.unpause()
f=stop_img
else:
pygame .mixer.music.pause()
f=play_img
if x>120 and x<220 and y>350 and y<400:
num-=1
if num<0:
num=len(music)-1
pygame.mixer.music.load(wq+'\\'+music[num])
pygame.mixer.music.play()
click=0
f=stop_img
if x>420 and x<520 and y>350 and y<400:
num+=1
if num>len(music)-1:
num=0
pygame.mixer.music.load(wq+'\\'+music[num])
pygame.mixer.music.play()
click=0
f=stop_img
if event.type==locals.QUIT: if event.type==locals.QUIT:
exit() exit()
if event.type==locals.KEYDOWN: if event.type==locals.KEYDOWN:
...@@ -30,14 +65,19 @@ while True: ...@@ -30,14 +65,19 @@ while True:
v=0 v=0
pygame.mixer.music.set_volume(v) pygame.mixer.music.set_volume(v)
if pygame.mixer.music.get_busy()==False: if pygame.mixer.music.get_busy()==False:
num+=1
if num>len(music)-1:
num=0
pygame.mixer.music.load(wq+'\\'+music[num])
pygame.mixer.music.play() pygame.mixer.music.play()
# 绘制画面 # 绘制画面
screen.blit(bg_img, (0, 0)) # 填充背景 screen.blit(bg_img, (0, 0)) # 填充背景
# 暂停按钮 # 暂停按钮
screen.blit(logo_img, (170, 60)) # 中间lohog图 # 中间flag图
screen.blit(last_img, (120, 350)) # 上一曲 screen.blit(last_img, (120, 350)) # 上一曲
screen.blit(next_img, (420, 350)) # 下一曲 screen.blit(next_img, (420, 350)) # 下一曲
screen.blit(f, (270, 330))
# 刷新画面 # 刷新画面
pygame.display.update() pygame.display.update()
File added
File added
File added
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