Mac Book 播放不了音乐
你好,我按照老师的做了,为什么播放不了
pygame,sys
import constants
def main():
pass
# intialize
pygame.init()
# size of the screen
# depend on the resolution of the drawing
width, height = 480, 852
# make screen
screen = pygame.display.set_mode((width, height))
# name the window
pygame.display.set_caption("Jet Fighter")
# load backgroud pictrue
bg = pygame.image.load(constants.BG_PIC)
# load BGM
pygame.mixer.music.load(constants.BG_MUSIC)
# repeat BGM
pygame.mixer.music.play(-1)
# set volume
pygame.mixer.music.set_volume(0.2)
while True:
for event in pygame.event.get():
# exist the game
if event.type == pygame.QUIT:
pygame.quit()
sys.exit()
#draw the background pic
screen.blit(bg,bg.get_rect())
pygame.display.flip()
if __name__ == "__main__":
main()
import os # root of the project BASE_DIR = os.path.dirname(os.path.abspath(__file__)) # static files directory STATIC_DIR = os.path.join(BASE_DIR, "static_resources") # Backgound pic BG_PIC = os.path.join(STATIC_DIR, "images/background.png") # BGM BG_MUSIC = os.path.join(STATIC_DIR, "bgm/game_bg_music.mp3")
正在回答 回答被采纳积分+1
- 参与学习 人
- 提交作业 2727 份
- 解答问题 8160 个
想要进入Python Web、爬虫、人工智能等高薪领域,你需要掌握本阶段的Python基础知识,课程安排带你高效学习轻松入门,学完你也能听得懂Python工程师的行业梗。
了解课程
恭喜解决一个难题,获得1积分~
来为老师/同学的回答评分吧
0 星