SBSPSS/source/fx/fxbaseanim.cpp

129 lines
3.0 KiB
C++
Raw Normal View History

2001-05-23 22:22:06 +02:00
/***********************/
2001-05-23 21:28:42 +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"
2001-05-25 20:43:47 +02:00
#include "game\game.h"
2001-06-01 00:02:07 +02:00
#include "level\layercollision.h"
2001-07-04 22:42:42 +02:00
2001-05-23 22:00:25 +02:00
#include "FX\FXBaseAnim.h"
2001-05-23 21:28:42 +02:00
2001-06-01 00:02:07 +02:00
2001-05-23 21:28:42 +02:00
/*****************************************************************************/
2001-05-23 22:00:25 +02:00
void CFXBaseAnim::init(DVECTOR const &_Pos)
2001-05-23 21:28:42 +02:00
{
2001-05-31 22:07:48 +02:00
CFX::init(_Pos);
CurrentFrame=0;
2001-06-19 23:19:01 +02:00
CurrentScaleX=CurrentScaleY=ONE;
2001-06-04 21:01:17 +02:00
CurrentHeading = 0;
2001-07-02 21:29:20 +02:00
HasInit=false;
2001-07-03 18:55:37 +02:00
Life=-1;
2001-06-19 23:19:01 +02:00
}
2001-06-01 00:02:07 +02:00
2001-06-19 23:19:01 +02:00
/*****************************************************************************/
void CFXBaseAnim::setBaseData(void *Data)
{
CFX::setBaseData(Data);
BaseData=(sFXBaseData*)Data;
2001-05-23 21:28:42 +02:00
}
/*****************************************************************************/
/*** Think *******************************************************************/
/*****************************************************************************/
2001-05-23 22:00:25 +02:00
void CFXBaseAnim::think(int _frames)
2001-05-23 21:28:42 +02:00
{
2001-07-02 21:29:20 +02:00
if (!HasInit)
{
MaxFrame=((BaseData->EndFrame-BaseData->StartFrame)<<BaseData->FrameShift)-1;
Flags|=BaseData->Flags;
renderFrame=BaseData->StartFrame;
2001-07-19 18:43:48 +02:00
if(m_soundId==NOT_PLAYING)
2001-07-04 22:42:42 +02:00
{
2001-07-19 18:43:48 +02:00
if (BaseData->StartSnd)
{
m_soundId=CSoundMediator::playSfx((CSoundMediator::SFXID)BaseData->StartSnd,true,true);
}
}
2001-07-24 21:48:17 +02:00
EndSnd=BaseData->EndSnd;
HasInit=true;
}
else
{
if ( !( Flags & FX_FLAG_HIDDEN ) )
2001-07-19 18:43:48 +02:00
{
2001-07-24 21:48:17 +02:00
if(m_soundId==NOT_PLAYING)
2001-07-19 18:43:48 +02:00
{
2001-07-24 21:48:17 +02:00
if (BaseData->MainSnd)
{
m_soundId=CSoundMediator::playSfx((CSoundMediator::SFXID)BaseData->MainSnd,true,true);
}
2001-07-19 18:43:48 +02:00
}
2001-07-04 22:42:42 +02:00
}
2001-07-02 21:29:20 +02:00
}
2001-05-23 21:28:42 +02:00
CFX::think(_frames);
2001-06-01 00:02:07 +02:00
2001-06-19 23:19:01 +02:00
if (BaseData->StartFrame!=BaseData->EndFrame)
2001-06-01 00:02:07 +02:00
{
2001-07-02 21:29:20 +02:00
CurrentFrame++;
2001-06-01 00:02:07 +02:00
2001-07-02 21:29:20 +02:00
if (CurrentFrame>MaxFrame)
2001-06-01 00:02:07 +02:00
{
2001-07-03 18:55:37 +02:00
if (Flags & FX_FLAG_LOOP)
{
CurrentFrame=0;
}
else
{
CurrentFrame=MaxFrame;
killFX();
}
2001-06-01 00:02:07 +02:00
}
2001-06-19 23:19:01 +02:00
int ThisFrame=CurrentFrame>>BaseData->FrameShift;
renderFrame=BaseData->StartFrame+ThisFrame;
2001-06-01 00:02:07 +02:00
}
2001-05-23 21:28:42 +02:00
2001-07-24 21:48:17 +02:00
if ( m_soundId != NOT_PLAYING )
{
if(!CSoundMediator::isSfxStillPlaying(m_soundId))
{
CSoundMediator::stopAndUnlockSfx(m_soundId);
m_soundId=NOT_PLAYING;
}
}
2001-06-01 00:02:07 +02:00
}
2001-05-23 21:28:42 +02:00
/*****************************************************************************/
/*** Render ******************************************************************/
/*****************************************************************************/
2001-05-23 22:00:25 +02:00
void CFXBaseAnim::render()
2001-05-23 21:28:42 +02:00
{
2001-07-03 00:51:10 +02:00
if (!HasInit) return;
2001-05-31 22:07:48 +02:00
2001-07-03 00:51:10 +02:00
DVECTOR RenderPos;
2001-05-31 22:07:48 +02:00
getFXRenderPos(RenderPos);
2001-06-19 23:19:01 +02:00
if (!canRender() || Flags & FX_FLAG_HIDDEN) return;
2001-05-23 21:28:42 +02:00
2001-05-25 20:43:47 +02:00
SpriteBank *SprBank=CGameScene::getSpriteBank();
2001-06-11 22:36:53 +02:00
POLY_FT4 *Ft4=SprBank->printRotatedScaledSprite(renderFrame,RenderPos.vx,RenderPos.vy,CurrentScaleX,CurrentScaleY,CurrentHeading,OtPos);
2001-05-31 22:07:48 +02:00
setShadeTex(Ft4,0);
2001-06-19 23:19:01 +02:00
setRGB0(Ft4,RGB.R,RGB.G,RGB.B);
setSemiTrans(Ft4,Flags & FX_FLAG_TRANS);
2001-06-12 01:37:59 +02:00
Frame=Ft4;
2001-08-08 00:40:27 +02:00
if (renderFrame==FRM__BUBBLE_2)
{
Ft4->u1++; Ft4->u3++;
Ft4->v2++; Ft4->v3++;
}
2001-05-23 21:28:42 +02:00
}
2001-06-07 18:33:19 +02:00