music changing
This commit is contained in:
parent
37e2c489a8
commit
a4aea4163a
@ -98,7 +98,6 @@ void GameObjectManager::initialize() {
|
||||
AddItemToInventory("RoomCeramics", testRoomTexture);
|
||||
AddItemToInventory("Cone", testConeTexture);
|
||||
|
||||
|
||||
roomTexturePtr = rooms[current_room_index].roomTexture;
|
||||
}
|
||||
|
||||
@ -107,8 +106,11 @@ void GameObjectManager::switch_room(int index){
|
||||
|
||||
roomTexturePtr = rooms[current_room_index].roomTexture;
|
||||
|
||||
audioPlayer.reset(); // This deletes the current AudioPlayer
|
||||
|
||||
// Reinitialize it
|
||||
audioPlayer = std::make_unique<AudioPlayer>();
|
||||
if (audioPlayer) {
|
||||
audioPlayer->stop();
|
||||
audioPlayer->playMusic(rooms[current_room_index].sound_name);
|
||||
}
|
||||
|
||||
|
||||
@ -143,7 +143,8 @@ bool AudioPlayer::playMusic(const std::string& filename) {
|
||||
alSourcei(musicSource, AL_BUFFER, musicBuffer);
|
||||
alSourcei(musicSource, AL_LOOPING, AL_TRUE); // Включаем зацикливание
|
||||
|
||||
std::cout << "▶️ Starting music playback...\n";
|
||||
std::cout << "▶️ Starting music playback... " << musicSource << std::endl;
|
||||
std::cout << "▶️ Music buffer... " << musicBuffer << std::endl;
|
||||
alSourcePlay(musicSource);
|
||||
|
||||
currentMusic = filename;
|
||||
|
||||
Loading…
Reference in New Issue
Block a user