|
马上注册,结交更多好友,享用更多功能^_^
您需要 登录 才可以下载或查看,没有账号?立即注册
x
import pygame
import sys
from pygame.locals import *
pygame.init()
pygame.mixer.init()
pygame.mixer.music.load("F:\工程\python\Battle02.mid")
pygame.mixer.music.set_volume(0.2)
pygame.mixer.music.play()
cat_sound = pygame.mixer.Sound("F:\工程\python\System02.ogg")
cat_sound.set_volume(0.2)
bg_size = width,height = 300,200
screen = pygame.display.set_mode(bg_size)
pygame.display.set_caption("音乐音效试水")
pause = False
pause_image = pygame.image.load("F:\工程\python\icon.png").convert_alpha()
unpause_image = pygame.image.load("F:\工程\python\Fighter01.png").convert_alpha()
pause_rect = pause_image.get_rect()
#图片放置于正中心
pause_rect.left,pause_rect.top = (width - pause_rect.width)//2,(height - pause_rect.height)//2
clock = pygame.time.Clock()
while True:
for event in pygame.event.get():
if event.type == QUIT:
sye.exit()
if event.type == MOUSEBUTTONDOWN:
if event.button == 1:
cat_sound.play()
if event.type == KEYDOWN:
if event.key == K_SPACE:
pause = not pause
screen.fill((255,255,255))
if pause:
screen.blit(pause_image,pause_rect)
pygame.mixer.music.pause()
else:
screen.blit(unpause_image,pause_rect)
pygame.mixer.music.unpause()
pygame.display.flip()
clock.tick(10)
你们这些基本上都是代码粗心打错了,自己检查一遍,用的图片和小甲鱼的一不一样
|
|