commit
b7f8a0f67a
@ -5,6 +5,7 @@
|
||||
|
||||
namespace ZL {
|
||||
struct ActiveObject {
|
||||
std::string name;
|
||||
std::shared_ptr<ZL::Texture> activeObjectTexturePtr;
|
||||
ZL::VertexDataStruct activeObjectMesh;
|
||||
ZL::VertexRenderStruct activeObjectMeshMutable;
|
||||
|
||||
@ -52,6 +52,7 @@ void GameObjectManager::initialize() {
|
||||
|
||||
// Create active object
|
||||
ActiveObject ao1;
|
||||
ao1.name = "book";
|
||||
ao1.activeObjectMesh = ZL::LoadFromTextFile("./book001.txt"); // Add ZL:: namespace
|
||||
ao1.activeObjectMesh.Scale(4);
|
||||
ao1.activeObjectMeshMutable.AssignFrom(ao1.activeObjectMesh);
|
||||
@ -91,13 +92,6 @@ void GameObjectManager::initialize() {
|
||||
inventoryIconMeshMutable.AssignFrom(inventoryIconMesh);
|
||||
inventoryIconMeshMutable.RefreshVBO();
|
||||
|
||||
|
||||
// Add test items to inventory
|
||||
auto testRoomTexture = std::make_shared<Texture>(CreateTextureDataFromBmp24("./Kitchen_ceramics.bmp"));
|
||||
auto testConeTexture = std::make_shared<Texture>(CreateTextureDataFromBmp24("./conus.bmp"));
|
||||
AddItemToInventory("RoomCeramics", testRoomTexture);
|
||||
AddItemToInventory("Cone", testConeTexture);
|
||||
|
||||
roomTexturePtr = rooms[current_room_index].roomTexture;
|
||||
}
|
||||
|
||||
@ -127,8 +121,17 @@ void GameObjectManager::handleEvent(const SDL_Event& event) {
|
||||
switch_room(1);
|
||||
}
|
||||
else if (event.type == SDL_MOUSEBUTTONDOWN) {
|
||||
bx.Interpolate(animationCounter);
|
||||
animationCounter += 2;
|
||||
for (size_t i = 0; i < activeObjects.size(); ++i) {
|
||||
auto& ao = activeObjects[i];
|
||||
if (ao.highlighted) {
|
||||
AddItemToInventory(ao.name, ao.activeObjectTexturePtr);
|
||||
activeObjects.erase(activeObjects.begin() + i);
|
||||
// Можно выйти из цикла, если объект удален, чтобы избежать ошибок индексации.
|
||||
break;
|
||||
}
|
||||
}
|
||||
// bx.Interpolate(animationCounter);
|
||||
// animationCounter += 2;
|
||||
}
|
||||
|
||||
else if (event.type == SDL_MOUSEWHEEL) {
|
||||
|
||||
@ -11,7 +11,7 @@ namespace ZL
|
||||
gInventory.push_back({ name, tex });
|
||||
}
|
||||
|
||||
void RemoveItemFromInventory(const std::string& name)
|
||||
void RemoveItemFromInventory(const std::string name)
|
||||
{
|
||||
gInventory.erase(
|
||||
std::remove_if(gInventory.begin(), gInventory.end(),
|
||||
|
||||
@ -94,6 +94,7 @@ void RenderSystem::drawUI(const GameObjectManager& gameObjects) {
|
||||
// Draw highlighted objects UI
|
||||
for (const auto& ao : gameObjects.activeObjects) {
|
||||
if (ao.highlighted) {
|
||||
if (ao.activeObjectScreenTexturePtr){
|
||||
int screenX, screenY;
|
||||
worldToScreenCoordinates(ao.objectPos, currentProjectionModelView,
|
||||
Environment::width, Environment::height, screenX, screenY);
|
||||
@ -102,6 +103,7 @@ void RenderSystem::drawUI(const GameObjectManager& gameObjects) {
|
||||
glBindTexture(GL_TEXTURE_2D, ao.activeObjectScreenTexturePtr->getTexID());
|
||||
renderer.DrawVertexRenderStruct(ao.activeObjectScreenMeshMutable);
|
||||
renderer.PopMatrix();
|
||||
} else {}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -20,7 +20,7 @@ public:
|
||||
private:
|
||||
void drawWorld(const GameObjectManager& gameObjects);
|
||||
void drawUI(const GameObjectManager& gameObjects);
|
||||
|
||||
|
||||
Renderer renderer;
|
||||
ShaderManager shaderManager;
|
||||
Matrix4f currentProjectionModelView; // Добавлено для хранения матрицы между drawWorld и drawUI
|
||||
|
||||
Loading…
Reference in New Issue
Block a user