SBSPSS/source/fx/fxnrgbar.cpp

96 lines
2.2 KiB
C++
Raw Normal View History

2001-05-31 00:05:41 +02:00
/******************/
/*** Energy Bar ***/
/******************/
2001-05-30 22:58:48 +02:00
#include "system\global.h"
2001-06-21 21:19:15 +02:00
#include "system\vid.h"
2001-05-30 22:58:48 +02:00
#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"
2001-05-31 00:05:41 +02:00
#include "FX\FXNRGBar.h"
#include "enemy\npc.h"
int NRGX=32;
int NRGY=188;
2001-06-21 21:19:15 +02:00
int NRGW=INGAME_SCREENW-64;
2001-05-30 22:58:48 +02:00
/*****************************************************************************/
/*****************************************************************************/
/*****************************************************************************/
2001-05-31 00:05:41 +02:00
void CFXNRGBar::init(DVECTOR const &_Pos)
2001-05-30 22:58:48 +02:00
{
CFX::init();
2001-05-31 00:05:41 +02:00
SpriteBank *SprBank=CGameScene::getSpriteBank();
2001-05-30 22:58:48 +02:00
2001-05-31 00:05:41 +02:00
GfxW=SprBank->getFrameWidth(FRM__BUBBLE_1);
GfxHalfW=GfxW/2;
DrawW=NRGW;
2001-05-30 22:58:48 +02:00
}
/*****************************************************************************/
/*** Think *******************************************************************/
/*****************************************************************************/
2001-05-31 00:05:41 +02:00
void CFXNRGBar::think(int _frames)
2001-05-30 22:58:48 +02:00
{
2001-05-31 00:05:41 +02:00
CNpcEnemy *P=(CNpcEnemy*)ParentThing;
int Health=P->getHealth();
2001-06-27 20:28:21 +02:00
if ( Health < 0 )
{
Health = 0;
}
2001-05-31 00:05:41 +02:00
CurrentW=((NRGW/MaxHealth)*Health);
int Diff=DrawW-CurrentW;
DrawW-=(Diff+1)>>1;
if (DrawW<=0 && Health==0)
{
2001-06-27 20:28:21 +02:00
//setToShutdown();
DrawW = 0;
2001-05-31 00:05:41 +02:00
}
2001-05-30 22:58:48 +02:00
}
/*****************************************************************************/
/*** Render ******************************************************************/
/*****************************************************************************/
2001-05-31 00:05:41 +02:00
void CFXNRGBar::render()
2001-05-30 22:58:48 +02:00
{
2001-05-31 00:05:41 +02:00
// 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;
2001-05-30 22:58:48 +02:00
}