SBSPSS/source/fx/fxsteam.cpp

125 lines
2.8 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-23 22:00:25 +02:00
#include "FX\FXBaseTrail.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-23 22:00:25 +02:00
CFXBaseTrail::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-06-08 15:35:08 +02:00
IsHorizontal=false;
2001-07-04 22:42:42 +02:00
m_soundId=CSoundMediator::playSfx( CSoundMediator::SFX_HAZARD__STEAM,true);
2001-05-18 16:17:13 +02:00
}
/*****************************************************************************/
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;
}
2001-06-08 15:35:08 +02:00
/*****************************************************************************/
void CFXSteam::SetVel(DVECTOR const &Velocity)
{
BaseVel.vx=Velocity.vx;
BaseVel.vy=Velocity.vy;
}
2001-05-21 20:11:30 +02:00
/*****************************************************************************/
2001-05-31 22:07:48 +02:00
void CFXSteam::killFX()
2001-05-21 20:11:30 +02:00
{
2001-05-31 22:07:48 +02:00
DieOut=true;
2001-05-23 00:30:36 +02:00
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;
2001-06-08 15:35:08 +02:00
if ( IsHorizontal )
{
Vel.vy+=getRndRange(3)-1;
}
else
{
Vel.vx+=getRndRange(3)-1;
}
2001-05-22 17:11:52 +02:00
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)
{
2001-07-04 22:42:42 +02:00
if( m_soundId != NOT_PLAYING )
{
CSoundMediator::stopAndUnlockSfx(m_soundId );
}
2001-05-22 17:11:52 +02:00
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