Skip to content

Commit

Permalink
Put hotbar Y pos into its own variable
Browse files Browse the repository at this point in the history
  • Loading branch information
IAmMoltony committed Dec 31, 2023
1 parent af92c23 commit 641879f
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
1 change: 1 addition & 0 deletions source/block.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -224,6 +224,7 @@ FlowerBlock::FlowerBlock(s16 x, s16 y) : Block(x, y, 1), type(FlowerType::Poppy)
type = FlowerType::Cornflower;
break;
}
// TODO why this no work
}

FlowerBlock::FlowerBlock(s16 x, s16 y, FlowerType type) : Block(x, y, 1), type(type),
Expand Down
11 changes: 6 additions & 5 deletions source/player.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -584,10 +584,11 @@ void Player::drawHUD(const Camera &camera, Font &font, Font &fontRu)
glColor(RGB15(31, 31, 31));

// hotbar drawing
int hotbarY = SCREEN_HEIGHT - 16;
for (u8 i = 0; i < NUM_HOTBAR_SLOTS; i++)
{
// draw the slot
glSprite(i * 16 + (SCREEN_WIDTH / 2 - (5 * 16 / 2)), SCREEN_HEIGHT - 16, GL_FLIP_NONE,
glSprite(i * 16 + (SCREEN_WIDTH / 2 - (5 * 16 / 2)), hotbarY, GL_FLIP_NONE,
(i == hotbarSelect ? sprInventorySlotSelect : sprInventorySlot));

// draw the item if it exists
Expand All @@ -598,7 +599,7 @@ void Player::drawHUD(const Camera &camera, Font &font, Font &fontRu)
u8 amount = inventory[i].amount;

int xxItem = i * 16 + (SCREEN_WIDTH / 2 - (5 * 16 / 2));
int yyItem = SCREEN_HEIGHT - 16;
int yyItem = hotbarY;

switch (id)
{
Expand Down Expand Up @@ -658,7 +659,7 @@ void Player::drawHUD(const Camera &camera, Font &font, Font &fontRu)

if (amount > 1)
font.printfShadow(i * 16 + (SCREEN_WIDTH / 2 - (5 * 16 / 2)) + 1,
SCREEN_HEIGHT - 9, "%u", amount);
hotbarY + 7, "%u", amount);
}
}

Expand All @@ -668,10 +669,10 @@ void Player::drawHUD(const Camera &camera, Font &font, Font &fontRu)
switch (Game::instance->lang)
{
case Language::English:
font.printShadowCentered(0, SCREEN_HEIGHT - 27, getItemName(inventory[hotbarSelect].id));
font.printShadowCentered(0, hotbarY - 11, getItemName(inventory[hotbarSelect].id));
break;
case Language::Russian:
fontRu.printShadowCentered(0, SCREEN_HEIGHT - 27, getItemName(inventory[hotbarSelect].id));
fontRu.printShadowCentered(0, hotbarY - 11, getItemName(inventory[hotbarSelect].id));
break;
}
}
Expand Down

0 comments on commit 641879f

Please sign in to comment.