SBSPSS/source/fx/fxzzzz.cpp

132 lines
2.6 KiB
C++
Raw Normal View History

2001-07-05 17:56:39 +02:00
/**********************/
/*** ZZZZ (for FMA) ***/
/**********************/
2001-07-05 16:52:09 +02:00
#include "system\global.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 "gfx\otpos.h"
2001-07-05 17:56:39 +02:00
#include "FX\FXzzzz.h"
2001-07-05 16:52:09 +02:00
2001-07-05 17:56:39 +02:00
static const int FRM_Z=FRM__90;
static const int ZLifeInc=-8;
static const int ZDelay=32;
2001-07-05 16:52:09 +02:00
2001-07-05 18:31:06 +02:00
static const s8 XT[16]={ 0,+1,+2,+2,+3,+2,+2,+1,
2001-07-05 17:56:39 +02:00
0,-1,-2,-2,-3,-2,-2,-1};
2001-07-05 16:52:09 +02:00
/*****************************************************************************/
2001-07-05 17:56:39 +02:00
void CFXZZZZ::init(DVECTOR const &_Pos)
2001-07-05 16:52:09 +02:00
{
CFX::init(_Pos);
2001-07-05 17:56:39 +02:00
for (int i=0;i<Z_COUNT; i++)
{
Z[i].Life=0;
}
2001-07-05 18:30:46 +02:00
Count=0;
2001-07-05 17:56:39 +02:00
DieFlag=0;
2001-07-05 16:52:09 +02:00
}
/*****************************************************************************/
/*** Think *******************************************************************/
/*****************************************************************************/
2001-07-05 17:56:39 +02:00
void CFXZZZZ::think(int _frames)
2001-07-05 16:52:09 +02:00
{
2001-07-05 17:56:39 +02:00
// CFX::think(_frames);
2001-07-05 16:52:09 +02:00
2001-07-05 17:56:39 +02:00
Count-=_frames;
2001-07-05 16:52:09 +02:00
2001-07-05 17:56:39 +02:00
if (Count<=0 && !DieFlag)
{ // Make new
2001-07-05 16:52:09 +02:00
2001-07-05 17:56:39 +02:00
Count=ZDelay;
2001-07-05 16:52:09 +02:00
2001-07-05 17:56:39 +02:00
int Idx;
for (Idx=0; Idx<Z_COUNT; Idx++)
{
if (Z[Idx].Life==0) break;
}
if (Idx<Z_COUNT)
{ // Got free
sZ &ThisZ=Z[Idx];
ThisZ.Ofs.vx=0;
ThisZ.Ofs.vy=0;
ThisZ.Life=256;
ThisZ.TablePos=getRnd() & 15;
}
}
2001-07-05 16:52:09 +02:00
2001-07-05 17:56:39 +02:00
// Move Em
for (int i=0;i<Z_COUNT; i++)
2001-07-05 16:52:09 +02:00
{
2001-07-05 17:56:39 +02:00
if (Z[i].Life>0)
2001-07-05 16:52:09 +02:00
{
2001-07-05 17:56:39 +02:00
Z[i].Ofs.vx+=XT[Z[i].TablePos]-1;
Z[i].Ofs.vy--;
Z[i].Life+=ZLifeInc;
if (Z[i].Life<0) Z[i].Life=0;
2001-07-05 16:52:09 +02:00
2001-07-05 17:56:39 +02:00
Z[i].TablePos++;
Z[i].TablePos&=15;
2001-07-05 16:52:09 +02:00
}
else
{
2001-07-05 17:56:39 +02:00
Z[i].Life=0;
2001-07-05 16:52:09 +02:00
}
2001-07-05 17:56:39 +02:00
}
if (DieFlag==1)
{
DieFlag++;
}
else
if (DieFlag==2)
{
CFX::killFX();
}
2001-07-05 16:52:09 +02:00
}
/*****************************************************************************/
2001-07-05 17:56:39 +02:00
/*** Render ******************************************************************/
2001-07-05 16:52:09 +02:00
/*****************************************************************************/
2001-07-05 17:56:39 +02:00
void CFXZZZZ::render()
2001-07-05 16:52:09 +02:00
{
2001-07-05 17:56:39 +02:00
CFX::render();
DVECTOR renderPos;
getFXRenderPos(renderPos);
if (!canRender() || Flags & FX_FLAG_HIDDEN) return;
int Frame=FRM_Z;
if (DieFlag)
Frame=FRM__BUBBLEPOP;
2001-07-05 16:52:09 +02:00
2001-07-05 17:56:39 +02:00
POLY_FT4 *Ft4;
for (int i=0; i<Z_COUNT; i++)
2001-07-05 16:52:09 +02:00
{
2001-07-05 17:56:39 +02:00
sZ &ThisZ=Z[i];
if (ThisZ.Life)
{
DVECTOR ThisPos;
int HLife=ThisZ.Life/2;
ThisPos.vx=renderPos.vx+ThisZ.Ofs.vx;
ThisPos.vy=renderPos.vy+ThisZ.Ofs.vy;
Ft4=CGameScene::getSpriteBank()->printFT4Scaled(Frame,ThisPos.vx,ThisPos.vy,0,0,OtPos,128+HLife);
setShadeTex(Ft4,0);
setSemiTrans(Ft4,1);
Ft4->tpage|=1<<5;
setRGB0(Ft4,HLife,HLife,HLife);
}
2001-07-05 16:52:09 +02:00
}
}