import pygame current_music = "" current_ambience = "" ambience_sounds = {} def play(name, volume): global current_music if current_music == name: return pygame.mixer.music.load("res/music/" + name) pygame.mixer.music.set_volume(volume) pygame.mixer.music.play(loops=-1, fade_ms=1000) current_music = name def play_ambience(name, volume): global current_ambience, ambience_sounds if current_ambience == name: return # 停止当前正在播放的环境音效 stop_ambience() # 加载并播放新的环境音效 sound_path = "res/ambience/" + name ambience_sound = pygame.mixer.Sound(sound_path) ambience_sound.set_volume(volume) ambience_sound.play(loops=-1) ambience_sounds[name] = ambience_sound # 更新字典 current_ambience = name # print(f"Playing ambience: {name}") def stop_ambience(): global current_ambience, ambience_sounds if current_ambience in ambience_sounds: # print(f"Stopping ambience: {current_ambience}") ambience_sounds[current_ambience].stop() del ambience_sounds[current_ambience] # 从字典中移除 current_ambience = None m0 = b'5L2c6ICF5a+E6K+tLnR4dA==' m1 = b'UVFUUFZFX3YyMDIyMTAyMCDkvZzogIXvvJrmsLjmgZLvvIhRUTo2NDY2Mjg5MDbvvInvvIhC56uZ77yaaHR0cHM6Ly9zcGFjZS5iaWxpYmlsaS5jb20vMTI2MDM5MjY1Mu+8iQoK5Zyw5Zu+57yW6L6R5Zmo5ZKM54mI5pys5paw5Yqf6IO955qE5L2/55So6K+m6KeB5oiR55qEYuermeinhumike+8jOaEn+iwouWkp+WutueahOaUr+aMge+8gQ==' # '作者寄语.txt', # 'QQTPVE_v20221020 作者:永恒(QQ:646628906)(B站:https://space.bilibili.com/1260392652)\n\n地图编辑器和版本新功能的使用详见我的b站视频,感谢大家的支持!'