From 07364460c33ce729dc8fe13b90e70a46ccd58e9c Mon Sep 17 00:00:00 2001 From: maka70vv <25.makarovv@gmail.com> Date: Mon, 3 Mar 2025 06:07:34 +0600 Subject: [PATCH] worked version of lamp --- GameObjectManager.cpp | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/GameObjectManager.cpp b/GameObjectManager.cpp index d70553d..d7ffb6b 100644 --- a/GameObjectManager.cpp +++ b/GameObjectManager.cpp @@ -316,11 +316,24 @@ void GameObjectManager::handleEvent(const SDL_Event& event) { std::cout << highlightedObjects.size() << std::endl; for (auto* ao : highlightedObjects) { if (ao && ao->name == "lampe") { -// ao->activeObjectTexturePtr = std::make_shared(CreateTextureDataFromBmp24("base_Base_color_1001.bmp")); - gInventoryMap.erase(item->name); - objects_in_inventory--; - break; - } + // Create a new lamp object with updated texture + ActiveObject updatedLamp = *ao; + // Change from dark to lit texture + updatedLamp.activeObjectTexturePtr = std::make_shared(CreateTextureDataFromBmp24("./base_Base_color_1001.bmp")); + + // Replace the old lamp with updated one + rooms[current_room_index].removeByPtr(ao); + rooms[current_room_index].objects.push_back(updatedLamp); + activeObjects = rooms[current_room_index].objects; + + // Remove car from inventory + gInventoryMap.erase(item->name); + objects_in_inventory--; + + // Play sound effect + audioPlayerAsync.playSoundAsync("lamp_on.ogg"); + break; + } } } }