getting room texture by index

This commit is contained in:
maka70vv 2025-03-02 00:51:39 +06:00
parent 74a2dc78a6
commit 5d31d8421f
3 changed files with 23 additions and 10 deletions

View File

@ -2,7 +2,6 @@
#include "Environment.h"
#include "ObjLoader.h"
#include "Inventory.h"
#include "Room.h"
#include "TextModel.h" // Add this include for LoadFromTextFile
namespace ZL {
@ -12,6 +11,8 @@ const float GameObjectManager::INVENTORY_MARGIN = 10.0f;
void GameObjectManager::initialize() {
current_room_index = 0;
std::cout << "Hello x1" << std::endl;
coneTexturePtr = std::make_shared<Texture>(CreateTextureDataFromBmp24("./conus.bmp"));
@ -63,6 +64,16 @@ void GameObjectManager::initialize() {
ao1.activeObjectScreenMeshMutable.RefreshVBO();
activeObjects.push_back(ao1);
Room room_1;
room_1.roomTexture = std::make_shared<Texture>(CreateTextureDataFromBmp24("./Kitchen_ceramics.bmp"));
// room_1.objects = ao1;
rooms.push_back(room_1);
Room room_2;
room_2.roomTexture = std::make_shared<Texture>(CreateTextureDataFromBmp24("./Kitchen_ceramics.bmp"));
rooms.push_back(room_2);
std::cout << "Hello x5" << std::endl;
@ -95,8 +106,8 @@ void GameObjectManager::initialize() {
std::cout << "Hello x8" << std::endl;
roomTexturePtr = std::make_shared<Texture>(CreateTextureDataFromBmp24("./Kitchen_ceramics.bmp"));
roomTexturePtr = rooms[current_room_index].roomTexture;
std::cout << "Current room" << current_room_index << std::endl;
}

View File

@ -5,6 +5,7 @@
#include <memory>
#include <vector>
#include "ActiveObject.h"
#include "Room.h"
#include <SDL2/SDL.h>
namespace ZL {
@ -37,6 +38,7 @@ public:
ZL::VertexRenderStruct coneMeshMutable;
std::vector<ZL::ActiveObject> activeObjects;
std::vector<ZL::Room> rooms;
std::unique_ptr<AudioPlayer> audioPlayer;
ZL::VertexDataStruct inventoryIconMesh;
@ -49,6 +51,7 @@ private:
int animationCounter = 0;
int lastMouseX = 0; // Добавляем переменные для хранения позиции мыши
int lastMouseY = 0;
int current_room_index;
bool isPointInObject(int screenX, int screenY, int objectScreenX, int objectScreenY) const;
void worldToScreenCoordinates(Vector3f objectPos, // Добавляем метод
Matrix4f projectionModelView,

13
Room.h
View File

@ -1,14 +1,13 @@
#pragma once
#include <string>
#include <vector>
#include <memory>
#include "TextureManager.h"
#include "Renderer.h"
#include "ObjLoader.h"
#include "Physics.h"
#include "Math.h"
#include <memory>
#include "ActiveObject.h"
namespace ZL
{
struct Room{
std::shared_ptr<ZL::Texture> roomTexture;
std::vector<ActiveObject> objects;
};
}