draw cubes
This commit is contained in:
parent
c39eac4241
commit
e8e4dc9b28
@ -8,10 +8,10 @@
|
|||||||
namespace ZL {
|
namespace ZL {
|
||||||
|
|
||||||
const float GameObjectManager::INVENTORY_ICON_SIZE = 44.0f;
|
const float GameObjectManager::INVENTORY_ICON_SIZE = 44.0f;
|
||||||
const float GameObjectManager::INVENTORY_MARGIN = 20.0f;
|
const float GameObjectManager::INVENTORY_MARGIN = 44.0f;
|
||||||
|
|
||||||
const float GameObjectManager::SELECTED_CUBE_ICON_SIZE = 44.0f;
|
const float GameObjectManager::SELECTED_CUBE_ICON_SIZE = 244.0f;
|
||||||
const float GameObjectManager::SELECTED_CUBE_MARGIN = 20.0f;
|
const float GameObjectManager::SELECTED_CUBE_MARGIN = 50.0f;
|
||||||
|
|
||||||
void GameObjectManager::initializeLoadingScreen()
|
void GameObjectManager::initializeLoadingScreen()
|
||||||
{
|
{
|
||||||
|
|||||||
@ -66,6 +66,8 @@ public:
|
|||||||
|
|
||||||
static const float INVENTORY_ICON_SIZE;
|
static const float INVENTORY_ICON_SIZE;
|
||||||
static const float INVENTORY_MARGIN;
|
static const float INVENTORY_MARGIN;
|
||||||
|
static const float SELECTED_CUBE_ICON_SIZE;
|
||||||
|
static const float SELECTED_CUBE_MARGIN;
|
||||||
ActiveObjectManager aoMgr;
|
ActiveObjectManager aoMgr;
|
||||||
int objects_in_inventory;
|
int objects_in_inventory;
|
||||||
void addRectangle(int x, int y, int width, int height, int r, int g, int b, int borderWidth, int borderR, int borderG, int borderB);
|
void addRectangle(int x, int y, int width, int height, int r, int g, int b, int borderWidth, int borderR, int borderG, int borderB);
|
||||||
@ -80,12 +82,12 @@ public:
|
|||||||
std::list<std::function<bool()>> loadingFunctions;
|
std::list<std::function<bool()>> loadingFunctions;
|
||||||
std::thread loadingThread;
|
std::thread loadingThread;
|
||||||
bool sideThreadLoadingCompleted = false;
|
bool sideThreadLoadingCompleted = false;
|
||||||
|
int current_room_index;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
//int animationCounter = 0;
|
//int animationCounter = 0;
|
||||||
int lastMouseX = 0; // Добавляем переменные для хранения позиции мыши
|
int lastMouseX = 0; // Добавляем переменные для хранения позиции мыши
|
||||||
int lastMouseY = 0;
|
int lastMouseY = 0;
|
||||||
int current_room_index;
|
|
||||||
bool isPointInObject(int screenX, int screenY, int objectScreenX, int objectScreenY) const;
|
bool isPointInObject(int screenX, int screenY, int objectScreenX, int objectScreenY) const;
|
||||||
void worldToScreenCoordinates(Vector3f objectPos, // Добавляем метод
|
void worldToScreenCoordinates(Vector3f objectPos, // Добавляем метод
|
||||||
Matrix4f projectionModelView,
|
Matrix4f projectionModelView,
|
||||||
|
|||||||
@ -11,7 +11,7 @@ namespace ZL
|
|||||||
return [](GameObjectManager& gom, size_t ms)
|
return [](GameObjectManager& gom, size_t ms)
|
||||||
{
|
{
|
||||||
if (gom.bearName.compare("TOM") == 0) {
|
if (gom.bearName.compare("TOM") == 0) {
|
||||||
std::cout << gom.bearName << std::endl;
|
gInventoryMap.clear();
|
||||||
gom.switch_room(1);
|
gom.switch_room(1);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|||||||
@ -263,6 +263,29 @@ void RenderSystem::drawUI(const GameObjectManager& gameObjects) {
|
|||||||
i++;
|
i++;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Отрисовка кубиков
|
||||||
|
if (gameObjects.current_room_index == 0){
|
||||||
|
for (const auto& cube : gameObjects.selectedCubes) {
|
||||||
|
renderer.PushMatrix();
|
||||||
|
|
||||||
|
// Смещаем по оси x: начиная с левой стороны и двигаясь вправо
|
||||||
|
float xPos = gameObjects.SELECTED_CUBE_MARGIN
|
||||||
|
+ i * (gameObjects.SELECTED_CUBE_ICON_SIZE + gameObjects.SELECTED_CUBE_MARGIN);
|
||||||
|
// Оставляем y константным
|
||||||
|
float yPos = Environment::height - gameObjects.SELECTED_CUBE_MARGIN - (gameObjects.SELECTED_CUBE_ICON_SIZE * 3.0f);
|
||||||
|
|
||||||
|
renderer.TranslateMatrix(Vector3f{xPos, yPos, 0.0f});
|
||||||
|
renderer.ScaleMatrix(Vector3f{2.8f, 2.8f, 1.0f});
|
||||||
|
glBindTexture(GL_TEXTURE_2D, cube.texture->getTexID());
|
||||||
|
|
||||||
|
renderer.DrawVertexRenderStruct(gameObjects.inventoryIconMeshMutable);
|
||||||
|
|
||||||
|
renderer.PopMatrix();
|
||||||
|
i++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
renderer.PopMatrix();
|
renderer.PopMatrix();
|
||||||
renderer.PopProjectionMatrix();
|
renderer.PopProjectionMatrix();
|
||||||
|
|
||||||
|
|||||||
@ -9,6 +9,7 @@ namespace ZL {
|
|||||||
class RenderSystem {
|
class RenderSystem {
|
||||||
public:
|
public:
|
||||||
RenderSystem() = default;
|
RenderSystem() = default;
|
||||||
|
Renderer renderer;
|
||||||
void initialize();
|
void initialize();
|
||||||
void drawScene(GameObjectManager& gameObjects);
|
void drawScene(GameObjectManager& gameObjects);
|
||||||
Renderer& getRenderer() { return renderer; }
|
Renderer& getRenderer() { return renderer; }
|
||||||
@ -26,7 +27,6 @@ private:
|
|||||||
|
|
||||||
void drawLoadingScreen(const GameObjectManager& gameObjects);
|
void drawLoadingScreen(const GameObjectManager& gameObjects);
|
||||||
|
|
||||||
Renderer renderer;
|
|
||||||
ShaderManager shaderManager;
|
ShaderManager shaderManager;
|
||||||
Matrix4f currentProjectionModelView; // Добавлено для хранения матрицы между drawWorld и drawUI
|
Matrix4f currentProjectionModelView; // Добавлено для хранения матрицы между drawWorld и drawUI
|
||||||
int lastMouseX = 0;
|
int lastMouseX = 0;
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user