Commit 8542a088 by BellCodeEditor

save project

parent 87966f8d
Showing with 3 additions and 8 deletions
import pygame
from pygame import locals
import os
pygame.init() # 初始化
# 创建窗口
screen = pygame.display.set_mode((640, 480))
......@@ -12,9 +11,8 @@ 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') # 下一曲按钮
music_list = []
path = "C:\\Users\\bellcode\\Desktop\\test"
path = "C:\Users\Administrator\Desktop\ksiwqqdj0dj20jj0dqq0jq0j0jw0cjc0j0j02jc0jc0jc0wcj0c0j0cj0cjcjicijwiojofjfiwjfojfowjfowjfoewjfojfiofewwwwwwwwwwwwwwwwwwwooooiejfiofjeojfeiofjiofjiofjewoifjewiofjewofjewioefjoifjewiofjewofjewofjewofjwofjwofjwojfofjwfjf"
filelist = os.listdir(path)
num = -1
for i in filelist:
......@@ -24,7 +22,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 +38,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 +60,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,14 +71,12 @@ 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()
# 绘制画面
screen.blit(bg_img, (0, 0)) # 填充背景
screen.blit(play_button, (270, 330)) # 暂停按钮
......@@ -92,3 +85,4 @@ while True:
screen.blit(next_img, (420, 350)) # 下一曲
# 刷新画面
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