SBSPSS/source/fx/fxsteam.cpp

110 lines
2.4 KiB
C++
Raw Normal View History

2001-05-18 22:54:43 +02:00
/*************/
/*** Steam ***/
/*************/
2001-05-18 16:17:13 +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"
2001-05-18 22:54:43 +02:00
#include "FX\FXSteam.h"
2001-05-18 16:17:13 +02:00
2001-05-23 21:27:05 +02:00
static const int DefSize=4*ONE;
2001-05-23 00:30:36 +02:00
static const int DefAngleInc=999;
static const int DefShadeBase=255;
static const int DefShadeDec=8;
static const int DefShadeDieDec=24;
2001-05-18 16:17:13 +02:00
/*****************************************************************************/
/*****************************************************************************/
/*****************************************************************************/
2001-05-18 22:54:43 +02:00
void CFXSteam::init(DVECTOR const &_Pos)
2001-05-18 16:17:13 +02:00
{
2001-05-21 20:11:30 +02:00
CFXTrail::init(_Pos);
2001-05-18 22:54:43 +02:00
Trans=3;
2001-05-23 00:30:36 +02:00
ShadeDec=DefShadeDec;
2001-05-21 20:11:30 +02:00
DieOut=false;
2001-05-23 00:30:36 +02:00
SetSize(DefSize);
2001-05-18 16:17:13 +02:00
}
/*****************************************************************************/
2001-05-18 22:54:43 +02:00
void CFXSteam::shutdown()
2001-05-18 16:17:13 +02:00
{
CFX::shutdown();
}
/*****************************************************************************/
2001-05-18 22:54:43 +02:00
void CFXSteam::SetSize(int Size)
2001-05-18 16:17:13 +02:00
{
2001-05-23 21:27:05 +02:00
Size>>=12;
2001-05-18 22:54:43 +02:00
ScaleInc=(4096/LIST_SIZE)*Size;
2001-05-21 20:11:30 +02:00
BaseVel.vx=0;
BaseVel.vy=-Size;
}
/*****************************************************************************/
void CFXSteam::setDie()
{
2001-05-23 00:30:36 +02:00
CFXTrail::setDie();
for (int i=0; i<LIST_SIZE; i++)
{ // Set drift off
sList &ThisElem=List[i];
ThisElem.Vel.vx+=getRndRange(9)-4; // give it x motion
}
ShadeDec=DefShadeDieDec;
ScaleInc=0;
2001-05-18 16:17:13 +02:00
}
/*****************************************************************************/
2001-05-18 22:54:43 +02:00
/*** Think *******************************************************************/
2001-05-18 16:17:13 +02:00
/*****************************************************************************/
2001-05-18 22:54:43 +02:00
void CFXSteam::think(int _frames)
2001-05-18 16:17:13 +02:00
{
2001-05-21 20:11:30 +02:00
CFX::think(_frames);
2001-05-18 16:17:13 +02:00
2001-05-22 17:11:52 +02:00
if (!DieOut)
{ // Replace Head
DVECTOR Vel=BaseVel;
Vel.vx+=getRndRange(3)-1;
sList &Head=moveHead();
Head.Ofs=Vel;
Head.Vel=Vel;
Head.Frame=FRM__SMOKE;
2001-05-23 00:30:36 +02:00
Head.Shade=DefShadeBase;
2001-05-22 17:11:52 +02:00
Head.Scale=ScaleInc;
Head.Angle=getRndRange(ONE);
}
2001-05-21 20:11:30 +02:00
// Move em all
int Head=HeadIdx;
2001-05-23 00:30:36 +02:00
int TotalLife=0;
2001-05-22 17:11:52 +02:00
for (int i=0; i<ListCount; i++)
2001-05-18 16:17:13 +02:00
{
2001-05-21 20:11:30 +02:00
sList &ThisElem=List[Head];
Head++;
Head&=LIST_SIZE-1;
ThisElem.Ofs.vx+=ThisElem.Vel.vx;
ThisElem.Ofs.vy+=ThisElem.Vel.vy;
2001-05-18 22:54:43 +02:00
2001-05-23 00:30:36 +02:00
ThisElem.Angle+=DefAngleInc;
2001-05-22 17:11:52 +02:00
ThisElem.Angle&=4095;
ThisElem.Scale+=ScaleInc;
ThisElem.Shade-=ShadeDec;
if (ThisElem.Shade<0) ThisElem.Shade=0;
TotalLife+=ThisElem.Shade;
2001-05-21 20:11:30 +02:00
}
2001-05-18 22:54:43 +02:00
2001-05-22 17:11:52 +02:00
if (DieOut && TotalLife==0)
{
setToShutdown();
2001-05-21 20:11:30 +02:00
}
2001-05-18 16:17:13 +02:00
}
2001-05-18 22:54:43 +02:00