SBSPSS/source/fx/fxgeyser.cpp

145 lines
3.3 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;
2001-07-20 20:01:51 +02:00
BasePos=_Pos;
2001-07-28 18:54:59 +02:00
OtPos+=3;
2001-08-08 00:36:28 +02:00
2001-07-13 15:49:58 +02:00
}
/*****************************************************************************/
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-08-13 15:51:43 +02:00
if (getParent())
{ // make huge box
setCollisionCentreOffset(0,-512/2);
setCollisionSize(32,512);
}
2001-06-19 23:19:01 +02:00
CFX::think(Frames);
2001-07-20 20:01:51 +02:00
Pos=BasePos;
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();
2001-07-20 20:01:51 +02:00
int W;
2001-06-19 23:19:01 +02:00
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
2001-08-22 17:05:27 +02:00
if ( SoundId == NOT_PLAYING && !GameScene.getIsPaused() )
2001-07-13 15:49:58 +02:00
{
2001-07-24 21:38:03 +02:00
SoundId = (int) CSoundMediator::playSfx(CSoundMediator::SFX_OIL_GEYSER,true);
2001-07-13 15:49:58 +02:00
}
2001-07-12 18:08:51 +02:00
}
else
{
Flags &= ~FX_FLAG_INJURE_PLAYER;
}
2001-06-19 23:19:01 +02:00
}
// top
2001-07-20 20:01:51 +02:00
Ft4=SprBank->printFT4(currentFrame,RenderPos.vx-8,RenderPos.vy-Height,0,0,OtPos);
2001-06-19 23:19:01 +02:00
setShadeTex(Ft4,0);
setRGB0(Ft4,RGB.R,RGB.G,RGB.B);
setSemiTrans(Ft4,Flags & FX_FLAG_TRANS);
2001-07-20 20:01:51 +02:00
W=(Ft4->x1-Ft4->x0)/2;
Ft4->x0-=W; Ft4->x1+=W;
Ft4->x2-=W; Ft4->x3+=W;
2001-07-28 18:54:59 +02:00
if (Height<8)
{
Ft4->x0+=2; Ft4->x1-=2;
Ft4->x2+=2; Ft4->x3-=2;
}
2001-06-19 21:56:41 +02:00
2001-08-13 15:51:43 +02:00
if (!Parent)
{
int FrameW=Ft4->x1-Ft4->x0;
setCollisionCentreOffset(FrameW>>1,-Height/2);
setCollisionCentreOffset(0,-Height/2);
setCollisionSize(FrameW,Height);
}
2001-06-19 23:19:01 +02:00
// Base
2001-07-20 20:01:51 +02:00
Ft4=SprBank->printFT4(FRM__GUSHBASE,RenderPos.vx-8,RenderPos.vy,currentFrame&2,0/*currentFrame&2*/,OtPos);
2001-06-19 23:19:01 +02:00
setShadeTex(Ft4,0);
setRGB0(Ft4,RGB.R,RGB.G,RGB.B);
setSemiTrans(Ft4,Flags & FX_FLAG_TRANS);
2001-07-20 20:01:51 +02:00
W=(Ft4->x1-Ft4->x0)/2;
Ft4->x0-=W+2; Ft4->x1+=W+2;
Ft4->x2-=W-2; Ft4->x3+=W-2;
2001-06-19 23:19:01 +02:00
Ft4->y0=Ft4->y2-Height;
Ft4->y1=Ft4->y3-Height;
2001-07-20 20:01:51 +02:00
Ft4->v0++; Ft4->v1++;
2001-06-19 23:19:01 +02:00
Ft4->v2--; Ft4->v3--;
2001-07-20 20:01:51 +02:00
2001-06-19 21:56:41 +02:00
}