SBSPSS/source/fx/fxnrgbar.cpp
Charles 14fe98ab08
2001-06-27 18:28:21 +00:00

96 lines
2.2 KiB
C++

/******************/
/*** Energy Bar ***/
/******************/
#include "system\global.h"
#include "system\vid.h"
#include <DStructs.h>
#include "utils\utils.h"
#include "gfx\prim.h"
#include "gfx\sprbank.h"
#include <sprites.h>
#include "level\level.h"
#include "game\game.h"
#include "FX\FXNRGBar.h"
#include "enemy\npc.h"
int NRGX=32;
int NRGY=188;
int NRGW=INGAME_SCREENW-64;
/*****************************************************************************/
/*****************************************************************************/
/*****************************************************************************/
void CFXNRGBar::init(DVECTOR const &_Pos)
{
CFX::init();
SpriteBank *SprBank=CGameScene::getSpriteBank();
GfxW=SprBank->getFrameWidth(FRM__BUBBLE_1);
GfxHalfW=GfxW/2;
DrawW=NRGW;
}
/*****************************************************************************/
/*** Think *******************************************************************/
/*****************************************************************************/
void CFXNRGBar::think(int _frames)
{
CNpcEnemy *P=(CNpcEnemy*)ParentThing;
int Health=P->getHealth();
if ( Health < 0 )
{
Health = 0;
}
CurrentW=((NRGW/MaxHealth)*Health);
int Diff=DrawW-CurrentW;
DrawW-=(Diff+1)>>1;
if (DrawW<=0 && Health==0)
{
//setToShutdown();
DrawW = 0;
}
}
/*****************************************************************************/
/*** Render ******************************************************************/
/*****************************************************************************/
void CFXNRGBar::render()
{
// CFX::render();
SpriteBank *SprBank=CGameScene::getSpriteBank();
POLY_FT4 *Ft4;
// Draw Start
Ft4=SprBank->printFT4(FRM__BUBBLE_1,NRGX,NRGY,0,0,0);
Ft4->x1-=GfxHalfW;
Ft4->x3-=GfxHalfW;
Ft4->u1-=GfxHalfW;
Ft4->u3-=GfxHalfW;
// Draw Start
Ft4=SprBank->printFT4(FRM__BUBBLE_1,NRGX+GfxHalfW,NRGY,0,0,0);
Ft4->x1+=DrawW-GfxW;
Ft4->x3+=DrawW-GfxW;
Ft4->u0+=GfxHalfW-1;
Ft4->u1-=GfxHalfW-1;
Ft4->u2+=GfxHalfW-1;
Ft4->u3-=GfxHalfW-1;
// Draw End
Ft4=SprBank->printFT4(FRM__BUBBLE_1,NRGX+DrawW+GfxHalfW,NRGY,0,0,0);
Ft4->x1-=GfxHalfW;
Ft4->x3-=GfxHalfW;
Ft4->u0+=GfxHalfW;
Ft4->u2+=GfxHalfW;
}