Don't show negative health on hud.

This commit is contained in:
Steve 2018-02-23 19:25:46 +00:00
parent f1c3b3e680
commit 01246d14b6
1 changed files with 6 additions and 4 deletions

View File

@ -108,7 +108,9 @@ void drawHud(void)
static void drawHealth(void)
{
int w;
int w, h;
h = MAX(world.bob->health, 0);
blitRect(atlasTexture->texture, 17, 17, &health->rect, 1);
@ -116,10 +118,10 @@ static void drawHealth(void)
drawRect(35, 8, w, 18, 0, 64, 0, 255);
w = world.bob->health * 12;
w = h * 12;
drawRect(35, 8, w, 18, 0, 225, 0, 255);
if (world.frameCounter % 60 < 30 && getPercent(world.bob->health, world.bob->healthMax) <= 33)
if (world.frameCounter % 60 < 30 && getPercent(h, world.bob->healthMax) <= 33)
{
drawRect(35, 8, w, 18, 255, 225, 255, 255);
}
@ -128,7 +130,7 @@ static void drawHealth(void)
drawOutlineRect(35, 8, w, 18, 0, 0, 0, 255);
drawText(35 + w + 5, 7, 14, TA_LEFT, colors.white, "%d", world.bob->health);
drawText(35 + w + 5, 7, 14, TA_LEFT, colors.white, "%d", h);
}
static void drawPower(void)