Commit 0d952854 by BellCodeEditor

save project

parent 1754f9f4
Showing with 10 additions and 3 deletions
import pygame
from pygame import locals
import random
pygame.init() # 初始化
# 创建窗口
a=random.randint(1,4)
if a==4:
b='.ogg'
else:
b='.wav'
screen = pygame.display.set_mode((640, 480))
# 载入图片、资源
bg_img = pygame.image.load('background.png') # 背景图
......@@ -13,7 +18,7 @@ next_img = pygame.image.load('next.png') # 下一曲按钮
logo_img = pygame.image.load('logo.png') # 下一曲按钮
# 载入音乐
pygame.mixer.music.load('歌曲4.ogg') # 载入音乐
pygame.mixer.music.load('歌曲'+str(a)+b) # 载入音乐
volume = 0.2
pygame.mixer.music.set_volume(volume) # 初始播放音量
......@@ -39,7 +44,9 @@ while True:
# 按下鼠标
if event.type == locals.MOUSEBUTTONDOWN:
# 次数增加
if event.button==1:
x,y=event.pos
if 270<x<370 and 350<y<450:
click += 1
if click % 2 == 0:
play_button = stop_img
......
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