scaling inventory obj
This commit is contained in:
parent
383b34f5d6
commit
1229e61702
@ -7,8 +7,8 @@
|
|||||||
|
|
||||||
namespace ZL {
|
namespace ZL {
|
||||||
|
|
||||||
const float GameObjectManager::INVENTORY_ICON_SIZE = 64.0f;
|
const float GameObjectManager::INVENTORY_ICON_SIZE = 44.0f;
|
||||||
const float GameObjectManager::INVENTORY_MARGIN = 10.0f;
|
const float GameObjectManager::INVENTORY_MARGIN = 20.0f;
|
||||||
|
|
||||||
void GameObjectManager::initialize() {
|
void GameObjectManager::initialize() {
|
||||||
|
|
||||||
@ -511,4 +511,35 @@ void GameObjectManager::worldToScreenCoordinates(Vector3f objectPos,
|
|||||||
screenY = (int)((1.0f + ndcY) * 0.5f * screenHeight);
|
screenY = (int)((1.0f + ndcY) * 0.5f * screenHeight);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void GameObjectManager::addRectangle(int x, int y, int width, int height, int r, int g, int b, int borderWidth, int borderR, int borderG, int borderB) {
|
||||||
|
// Преобразование RGB в диапазон [0,1] для OpenGL
|
||||||
|
float rf = r / 255.0f;
|
||||||
|
float gf = g / 255.0f;
|
||||||
|
float bf = b / 255.0f;
|
||||||
|
float borderRf = borderR / 255.0f;
|
||||||
|
float borderGf = borderG / 255.0f;
|
||||||
|
float borderBf = borderB / 255.0f;
|
||||||
|
|
||||||
|
// Отрисовка заполненного прямоугольника
|
||||||
|
glColor3f(rf, gf, bf);
|
||||||
|
glBegin(GL_QUADS);
|
||||||
|
glVertex2f(x, y);
|
||||||
|
glVertex2f(x + width, y);
|
||||||
|
glVertex2f(x + width, y + height);
|
||||||
|
glVertex2f(x, y + height);
|
||||||
|
glEnd();
|
||||||
|
|
||||||
|
// Отрисовка рамки
|
||||||
|
if (borderWidth > 0) {
|
||||||
|
glColor3f(borderRf, borderGf, borderBf);
|
||||||
|
glLineWidth(borderWidth);
|
||||||
|
glBegin(GL_LINE_LOOP);
|
||||||
|
glVertex2f(x, y);
|
||||||
|
glVertex2f(x + width, y);
|
||||||
|
glVertex2f(x + width, y + height);
|
||||||
|
glVertex2f(x, y + height);
|
||||||
|
glEnd();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
} // namespace ZL
|
} // namespace ZL
|
||||||
|
|||||||
@ -56,6 +56,8 @@ public:
|
|||||||
static const float INVENTORY_MARGIN;
|
static const float INVENTORY_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);
|
||||||
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
//int animationCounter = 0;
|
//int animationCounter = 0;
|
||||||
|
|||||||
@ -9,16 +9,12 @@ namespace ZL
|
|||||||
std::function<void(GameObjectManager&, size_t)> createRoom1Logic()
|
std::function<void(GameObjectManager&, size_t)> createRoom1Logic()
|
||||||
{
|
{
|
||||||
return [](GameObjectManager& gom, size_t ms)
|
return [](GameObjectManager& gom, size_t ms)
|
||||||
// Simple test logic
|
|
||||||
{
|
{
|
||||||
if (GetItemByName("book")) {
|
|
||||||
std::cout << "[Room 1] Игрок поднял книгу!\n";
|
|
||||||
|
|
||||||
gom.switch_room(1);
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
std::function<void(GameObjectManager&, size_t)> createRoom2Logic()
|
std::function<void(GameObjectManager&, size_t)> createRoom2Logic()
|
||||||
{
|
{
|
||||||
return [](GameObjectManager& gom, size_t ms)
|
return [](GameObjectManager& gom, size_t ms)
|
||||||
|
|||||||
@ -237,11 +237,12 @@ void RenderSystem::drawUI(const GameObjectManager& gameObjects) {
|
|||||||
if (item.isSelected) {
|
if (item.isSelected) {
|
||||||
float xPos = Environment::width
|
float xPos = Environment::width
|
||||||
- gameObjects.INVENTORY_MARGIN
|
- gameObjects.INVENTORY_MARGIN
|
||||||
- gameObjects.INVENTORY_ICON_SIZE+25;
|
- gameObjects.INVENTORY_ICON_SIZE;
|
||||||
float yPos = gameObjects.INVENTORY_MARGIN
|
float yPos = gameObjects.INVENTORY_MARGIN
|
||||||
+ i * (gameObjects.INVENTORY_ICON_SIZE+25
|
+ i * (gameObjects.INVENTORY_ICON_SIZE
|
||||||
+ gameObjects.INVENTORY_MARGIN);
|
+ gameObjects.INVENTORY_MARGIN);
|
||||||
renderer.TranslateMatrix(Vector3f{xPos, yPos, 0.0f});
|
renderer.TranslateMatrix(Vector3f{xPos, yPos, 0.0f});
|
||||||
|
renderer.ScaleMatrix(Vector3f{1.5f, 1.5f, 1.0f});
|
||||||
glBindTexture(GL_TEXTURE_2D, item.texture->getTexID());
|
glBindTexture(GL_TEXTURE_2D, item.texture->getTexID());
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user