SBSPSS/source/fx/fxgeyser.cpp

119 lines
2.8 KiB
C++
Raw Normal View History

2001-06-19 21:56:41 +02:00
/***********************/
/*** Anim Base Class ***/
/***********************/
#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"
2001-06-19 23:19:01 +02:00
#include "FX\FXGeyser.h"
2001-06-19 21:56:41 +02:00
2001-06-21 21:19:15 +02:00
static const int GeyserSpeed=4;
2001-06-19 21:56:41 +02:00
/*****************************************************************************/
2001-06-19 23:19:01 +02:00
void CFXGeyser::init(DVECTOR const &_Pos)
2001-06-19 21:56:41 +02:00
{
2001-06-19 23:19:01 +02:00
CFX::init(_Pos);
2001-06-19 21:56:41 +02:00
Height=TargetHeight=8;
2001-06-19 23:19:01 +02:00
currentFrame=FRM__GUSH000;
2001-07-13 15:49:58 +02:00
SoundId = NOT_PLAYING;
}
/*****************************************************************************/
void CFXGeyser::shutdown()
{
if ( SoundId != NOT_PLAYING )
{
CSoundMediator::stopAndUnlockSfx( (xmPlayingId) SoundId );
}
CFX::shutdown();
2001-06-19 21:56:41 +02:00
}
/*****************************************************************************/
2001-06-19 23:19:01 +02:00
void CFXGeyser::think(int Frames)
2001-06-19 21:56:41 +02:00
{
2001-06-19 23:19:01 +02:00
CFX::think(Frames);
2001-06-19 21:56:41 +02:00
2001-06-19 23:19:01 +02:00
currentFrame++;
if (currentFrame>FRM__GUSH003)
2001-06-19 21:56:41 +02:00
{
2001-06-19 23:19:01 +02:00
currentFrame=FRM__GUSH000;
2001-06-19 21:56:41 +02:00
}
2001-06-19 23:35:02 +02:00
// TargetHeight=MaxHeight;
2001-06-19 21:56:41 +02:00
}
2001-06-19 23:19:01 +02:00
2001-06-19 21:56:41 +02:00
/*****************************************************************************/
/*** Render ******************************************************************/
/*****************************************************************************/
2001-06-19 23:19:01 +02:00
void CFXGeyser::render()
2001-06-19 21:56:41 +02:00
{
2001-06-19 23:19:01 +02:00
DVECTOR RenderPos;
POLY_FT4 *Ft4;
SpriteBank *SprBank=CGameScene::getSpriteBank();
CThing *Parent=getParent();
getFXRenderPos(RenderPos);
2001-06-19 21:56:41 +02:00
if (!canRender() || Flags & FX_FLAG_HIDDEN) return;
2001-07-13 15:49:58 +02:00
if( SoundId != NOT_PLAYING && !CSoundMediator::isSfxStillPlaying( (xmPlayingId) SoundId ) )
{
// unlock sound if it has finished
CSoundMediator::stopAndUnlockSfx( (xmPlayingId) SoundId );
SoundId = NOT_PLAYING;
}
2001-06-19 23:19:01 +02:00
// is it attached to a platform?
if (Parent)
{ // yes, so get pos, and return
Height=RenderPos.vy-Parent->getRenderPos().vy;
}
else
{
int HDiff=TargetHeight-Height;
Height+=(HDiff+(GeyserSpeed-1))/GeyserSpeed;
2001-07-12 18:08:51 +02:00
if ( Height > 10 )
{
Flags |= FX_FLAG_INJURE_PLAYER;
2001-07-13 15:49:58 +02:00
if ( SoundId == NOT_PLAYING )
{
SoundId = (int) CSoundMediator::playSfx(CSoundMediator::SFX_WORLD_OBJECT__GEYSER,true);
}
2001-07-12 18:08:51 +02:00
}
else
{
Flags &= ~FX_FLAG_INJURE_PLAYER;
}
2001-06-19 23:19:01 +02:00
}
// top
Ft4=SprBank->printFT4(currentFrame,RenderPos.vx,RenderPos.vy-Height,0,0,OtPos);
setShadeTex(Ft4,0);
setRGB0(Ft4,RGB.R,RGB.G,RGB.B);
setSemiTrans(Ft4,Flags & FX_FLAG_TRANS);
2001-06-19 21:56:41 +02:00
2001-06-19 23:19:01 +02:00
int FrameW=Ft4->x1-Ft4->x0;
setCollisionCentreOffset(FrameW>>1,-Height/2);
setCollisionCentreOffset(0,-Height/2);
setCollisionSize(FrameW,Height);
2001-06-19 21:56:41 +02:00
2001-06-19 23:19:01 +02:00
// Base
Ft4=SprBank->printFT4(FRM__GUSHBASE,RenderPos.vx,RenderPos.vy,0,0,OtPos);
setShadeTex(Ft4,0);
setRGB0(Ft4,RGB.R,RGB.G,RGB.B);
setSemiTrans(Ft4,Flags & FX_FLAG_TRANS);
Ft4->y0=Ft4->y2-Height;
Ft4->y1=Ft4->y3-Height;
Ft4->v2--; Ft4->v3--;
2001-06-19 21:56:41 +02:00
}