cave-story-solaris/src/BossLife.cpp
2019-01-31 14:36:54 +00:00

84 lines
1.4 KiB
C++

#include "BossLife.h"
#include "Draw.h"
#include "NpChar.h"
#include "WindowsWrapper.h"
static struct
{
bool flag;
int *pLife;
int max;
int br;
int count;
} gBL;
void InitBossLife(void)
{
gBL.flag = false;
}
bool StartBossLife(int code_event)
{
for (int i = 0; i < 0x200; ++i)
{
if (gNPC[i].code_event == code_event)
{
gBL.flag = true;
gBL.max = gNPC[i].life;
gBL.br = gNPC[i].life;
gBL.pLife = &gNPC[i].life;
return true;
}
}
return false;
}
bool StartBossLife2(void)
{
// TODO uncomment me when Boss.cpp is done!
// gBL.flag = true;
// gBL.max = gBoss[0].life;
// gBL.br = gBoss[0].life;
// gBL.pLife = &gBoss[0].life;
return true;
}
void PutBossLife(void)
{
RECT rcText = {0, 48, 32, 56};
RECT rcBox1 = {0, 0, 244, 8};
RECT rcBox2 = {0, 16, 244, 24};
RECT rcLife = {0, 24, 0, 32};
RECT rcBr = {0, 32, 232, 40};
if (gBL.flag)
{
if (*gBL.pLife >= 1)
{
rcLife.right = 198 * *gBL.pLife / gBL.max;
if (gBL.br <= *gBL.pLife)
{
gBL.count = 0;
}
else if (++gBL.count > 30)
{
--gBL.br;
}
rcBr.right = 198 * gBL.br / gBL.max;
PutBitmap3(&grcGame, 32, 220, &rcBox1, SURFACE_ID_TEXT_BOX);
PutBitmap3(&grcGame, 32, 228, &rcBox2, SURFACE_ID_TEXT_BOX);
PutBitmap3(&grcGame, 72, 224, &rcBr, SURFACE_ID_TEXT_BOX);
PutBitmap3(&grcGame, 72, 224, &rcLife, SURFACE_ID_TEXT_BOX);
PutBitmap3(&grcGame, 40, 224, &rcText, SURFACE_ID_TEXT_BOX);
}
else
{
gBL.flag = false;
}
}
}