adding battery to the lamp

This commit is contained in:
maka70vv 2025-03-03 04:53:37 +06:00
parent d0c49843af
commit 146644b3db
2 changed files with 27 additions and 6 deletions

View File

@ -143,8 +143,7 @@ void GameObjectManager::initialize() {
lampe.activeObjectScreenMesh = CreateRect2D({ 0.f, 0.f }, { 64.f, 64.f }, 0.5);
lampe.activeObjectScreenMeshMutable.AssignFrom(lampe.activeObjectScreenMesh);
lampe.activeObjectScreenMeshMutable.RefreshVBO();
lampe.inventoryIconTexturePtr = std::make_shared<Texture>(CreateTextureDataFromBmp32("./textures/inventory_objects/cubic_T_icon.bmp32"));
lampe.inventoryIconTexturePtr = std::make_shared<Texture>(CreateTextureDataFromBmp32("./textures/inventory_objects/battery.bmp32"));
ActiveObject carToy;
@ -159,9 +158,7 @@ void GameObjectManager::initialize() {
carToy.activeObjectScreenMesh = CreateRect2D({ 0.f, 0.f }, { 64.f, 64.f }, 0.5);
carToy.activeObjectScreenMeshMutable.AssignFrom(carToy.activeObjectScreenMesh);
carToy.activeObjectScreenMeshMutable.RefreshVBO();
carToy.inventoryIconTexturePtr = std::make_shared<Texture>(CreateTextureDataFromBmp32("./textures/inventory_objects/cubic_T_icon.bmp32"));
carToy.inventoryIconTexturePtr = std::make_shared<Texture>(CreateTextureDataFromBmp32("./textures/inventory_objects/battery.bmp32"));
Room room_1;
@ -309,6 +306,28 @@ void GameObjectManager::handleEvent(const SDL_Event& event) {
selectedCubes.clear();
}
}
else if (current_room_index==1) {
if (InventoryItem* item = GetItemSelected(true)){
std::cout << item->name << std::endl;
if (item->name == "carToy") {
std::cout << item->name << std::endl;
// Проверить, наведена ли мышь на лампу
const auto highlightedObjects = rooms[current_room_index].findByHighlighted(true);
std::cout << highlightedObjects.size() << std::endl;
for (auto* ao : highlightedObjects) {
if (ao && ao->name == "lampe") {
std::cout << "Battery added to the lamp!" << std::endl;
// Здесь можно реализовать включение лампы или другую логику
// Убираем батарейку из инвентаря
gInventoryMap.erase(item->name);
objects_in_inventory--;
break;
}
}
}
}
}
}
else {
const auto highlightedObjects = rooms[current_room_index].findByHighlighted(true);
@ -318,11 +337,13 @@ void GameObjectManager::handleEvent(const SDL_Event& event) {
continue;
}
if (ao->name != "lampe") {
AddItemToInventory(ao->name, ao->inventoryIconTexturePtr, objects_in_inventory+1);
objects_in_inventory++;
rooms[current_room_index].removeByPtr(ao);
activeObjects = rooms[current_room_index].objects;
}
//aoMgr.removeByName(ao->name);
@ -331,7 +352,7 @@ void GameObjectManager::handleEvent(const SDL_Event& event) {
// animationCounter += 2;
}
}
gi
else if (event.type == SDL_MOUSEWHEEL) {
static const float zoomstep = 1.0f;
if (event.wheel.y > 0) {

Binary file not shown.

After

Width:  |  Height:  |  Size: 344 KiB