pygame播放音乐有错误
代码:import pygame
import os
import sys
import traceback
from pygame.locals import *
pygame.init()
pygame.mixer.init()
bg_size = width, height = 480, 700
screen = pygame.display.set_mode(bg_size)
pygame.display.set_caption("飞机大战—改进版")
# backgroung = pygame.image.load("images/background.png").convert()
backgroung = pygame.image.load(os.path.join('./images/', 'background.png')).convert()
pygame.mixer.music.load("sound/game_music.ogg")
pygame.mixer.music.set_volume(0.2)
bullet_sound = pygame.mixer.Sound("sound/bullet.wav")
bullet_sound.set_volume(0.2)
bomb_sound = pygame.mixer.Sound("sound/use_bomb.wav")
bomb_sound.set_volume(0.2)
supply_sound = pygame.mixer.Sound("sound/supply.wav")
supply_sound.set_volume(0.2)
def main():
pygame.mixer.music.play(-1)
clock = pygame.time.Clock()
running = True
while running:
for event in pygame.event.get():
if event.type == pygame.QUIT:
pygame.quit()
sys.exit()
screen.blit(backgroung, (0, 0))
pygame.display.flip()
clock.tick(60)
if __name__ == '__main__':
main()
弹出的错误:
Traceback (most recent call last):
File "F:/python/飞机大战YC/main.py", line 18, in <module>
pygame.mixer.music.load("sound/game_music.ogg")
pygame.error: Failed loading libvorbisfile-3.dll: 找不到指定的模块。
Process finished with exit code 1
和视频上的一样啊,就减少了重复的添加的音乐。很郁闷。。。
本帖最后由 Py与C。。。 于 2022-7-25 11:28 编辑
搜索(找不到就下载)libvorbisfile-3.dll,复制到C:\Windows\System32与C:\Windows\SysWOW64中
ps : (修改后)我也有同样的问题,这是从网上搜的,亲测无效,但不知道你有没有效果
页:
[1]