SBSPSS/source/fx/fxnrgbar.cpp

95 lines
2.3 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"
2001-07-16 18:09:16 +02:00
#include "FX\FXBubble.h"
2001-05-30 22:58:48 +02:00
2001-07-16 18:09:16 +02:00
const int NRGX=32;
const int NRGY=188;
const 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;
2001-07-16 18:09:16 +02:00
CurrentHealth=0;
}
/*****************************************************************************/
void CFXNRGBar::SetMax(int Max)
{
MaxHealth=Max;
Scale=((NRGW*4096)/32)/MaxHealth;
XInc=NRGW/MaxHealth;
CurrentHealth=Max;
2001-05-30 22:58:48 +02:00
}
/*****************************************************************************/
/*** Think *******************************************************************/
/*****************************************************************************/
2001-07-16 18:09:16 +02:00
//int NRGMax=16;
//int NRGH=NRGMax;
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;
2001-07-16 18:09:16 +02:00
int Health=P->getHealth();
2001-06-27 20:28:21 +02:00
2001-07-16 18:09:16 +02:00
// SetMax(NRGMax);
// Health=NRGH;
2001-05-31 00:05:41 +02:00
2001-07-16 18:09:16 +02:00
if (CurrentHealth<Health) CurrentHealth=Health;
if (CurrentHealth>Health)
2001-05-31 00:05:41 +02:00
{
2001-07-16 18:09:16 +02:00
CurrentHealth--;
for (int b=0; b<4; b++)
{
DVECTOR Pos;
Pos.vx=NRGX+(CurrentHealth*XInc);
Pos.vy=NRGY;
CFXBubble *FX=(CFXBubble*)CFX::Create(CFX::FX_TYPE_BUBBLE_WATER,Pos);
FX->Flags|=FX_FLAG_SCREEN_FX;
FX->SetOtPos(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();
2001-07-16 18:09:16 +02:00
int x=NRGX;
2001-05-31 00:05:41 +02:00
SpriteBank *SprBank=CGameScene::getSpriteBank();
POLY_FT4 *Ft4;
2001-07-16 18:09:16 +02:00
for (int i=0; i<CurrentHealth; i++)
{
Ft4=SprBank->printRotatedScaledSprite(FRM__BUBBLE_1,x,NRGY,Scale,Scale,0,0);
x+=XInc;
}
2001-05-31 00:05:41 +02:00
2001-05-30 22:58:48 +02:00
}