Commit d518abb1 by BellCodeEditor

save project

parent 67c35067
Showing with 11 additions and 0 deletions
import pygame import pygame
from pygame import locals from pygame import locals
volume=0.5 volume=0.5
pygame.init() # 初始化 pygame.init() # 初始化
# 创建窗口 # 创建窗口
screen = pygame.display.set_mode((640, 480)) screen = pygame.display.set_mode((640, 480))
...@@ -12,6 +13,8 @@ last_img = pygame.image.load('last.png') # 上一曲按钮 ...@@ -12,6 +13,8 @@ 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('歌曲4.ogg') pygame.mixer.music.load('歌曲4.ogg')
c=0
play_button = stop_img
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:
...@@ -27,6 +30,14 @@ while True: ...@@ -27,6 +30,14 @@ while True:
if volume >= 1.0: if volume >= 1.0:
volume=1 volume=1
pygame.mixer.music.set_volume(volume) pygame.mixer.music.set_volume(volume)
if event.type == locals.MOUSEBUTTONDOWN:
c += 1
if c%2==0:
play_button = stop_img
pygame.mixer.music.unpause()
else:
play_button = play_img
pygame.mixer.music.pause()
if pygame.mixer.music.get_busy()==False: if pygame.mixer.music.get_busy()==False:
pygame.mixer.music.play() pygame.mixer.music.play()
......
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