Commit 8cfd91ec by BellCodeEditor

save project

parent 3104cbf1
Showing with 13 additions and 10 deletions
import pygame import pygame
from pygame import locals from pygame import locals
pygame.init() # 初始化 pygame.init() # 初始化
# 创建窗口 # 创建窗口
screen = pygame.display.set_mode((640, 480)) screen = pygame.display.set_mode((640, 480))
...@@ -13,16 +13,19 @@ stop_img = pygame.image.load('stop.png') # 暂停按钮 ...@@ -13,16 +13,19 @@ 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 logo_img = pygame.image.load('logo.png') # 中间logo
pygame.mixer.music.load('歌曲1.wav')#预加载音乐 pygame.mixer.music.load('歌曲3.wav') #预加载歌曲3
FPSCLOCK = pygame.time.Clock()#时钟 volume = 0.2 #音乐音量变量
pygame.mixer.music.set_volume(volume) #设置音乐音量
while True: while True:
for event in pygame.event.get(): for event in pygame.event.get(): #生成所有事件
if event.type == locals.QUIT:#当点击退出键 if event.type == locals.QUIT: #当点击退出键
exit()#退出 exit() #退出
if pygame.mixer.music.get_busy() == False:#音乐是否正在播放 if pygame.mixer.music.get_busy() == False: #检测音乐是否正在播放-如果不在播放
pygame.mixer.music.play()#播放音乐 pygame.mixer.music.play() #播放音乐
# 绘制画面 # 绘制画面
screen.blit(bg_img, (0, 0)) # 填充背景 screen.blit(bg_img, (0, 0)) # 填充背景
...@@ -32,4 +35,4 @@ while True: ...@@ -32,4 +35,4 @@ while True:
screen.blit(next_img, (420, 350)) # 下一曲 screen.blit(next_img, (420, 350)) # 下一曲
# 刷新画面 # 刷新画面
pygame.display.update() pygame.display.update()
FPSCLOCK.tick(3)
\ No newline at end of file \ 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