| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364 |
- import pygame
- import client_local.const.game as G
- current_music = ""
- current_ambience = ""
- ambience_sounds = {}
- def play(name, volume):
- global current_music
- try:
- if current_music == name:
- pygame.mixer.music.set_volume(volume)
- return
- pygame.mixer.music.load(f"res/music/{name}")
- pygame.mixer.music.set_volume(volume)
- pygame.mixer.music.play(loops=-1, fade_ms=1000)
- current_music = name
- except Exception as e:
- print(e)
- def stop_music():
- global current_music
- try:
- pygame.mixer.music.stop()
- except Exception as e:
- print(e)
- current_music = ""
- def play_ambience(name, volume):
- global current_ambience, ambience_sounds
- if current_ambience == name and name in ambience_sounds:
- ambience_sounds[name].set_volume(volume)
- return
- # 停止当前正在播放的环境音效
- stop_ambience()
- # 加载并播放新的环境音效
- try:
- 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}")
- except Exception as e:
- print(e)
- 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站视频,感谢大家的支持!'
|