修改音频文件为相对路径,移动文件到data目录,复用data目录获取函数

This commit is contained in:
2026-07-27 22:49:56 +08:00
parent 90f734158b
commit 805704f0e5
2 changed files with 5 additions and 1 deletions
+5 -1
View File
@@ -6,7 +6,10 @@
# Datetime: 2026/7/25 下午10:44
# Description:
# ---------------------------------------------------------------------------
import os
import pygame
from src.config.game_config import data_path
# 初始化pygame
pygame.init()
@@ -22,7 +25,8 @@ screen = pygame.display.set_mode(size)
pygame.display.set_caption("New_game")
# 播放并循环音乐
pygame.mixer_music.load(r'D:\python_project\Game_project\file\vespidaze-upbeat-rpg-battle-460971.mp3')
data_path = data_path()
pygame.mixer_music.load(os.path.join(data_path, "vespidaze-upbeat-rpg-battle-460971.mp3"))
pygame.mixer_music.play(-1)
# 状态值