This commit is contained in:
Daveo 2001-06-01 14:05:21 +00:00
parent 4f90ba2bfa
commit ecf44a21e2
2 changed files with 156 additions and 0 deletions

106
source/fx/fxbubble.cpp Normal file
View File

@ -0,0 +1,106 @@
/***********************/
/*** 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"
#include "level\layercollision.h"
#include "FX\FXBaseAnim.h"
/*****************************************************************************/
void CFXBaseAnim::init(DVECTOR const &_Pos)
{
CFX::init(_Pos);
CurrentFrame=0;
CurrentScale=DataPtr->Scale;
MaxFrame=((DataPtr->EndFrame-DataPtr->StartFrame)<<DataPtr->FrameShift)-1;
if (DataPtr->Flags & FXANIM_FLAG_LOOP)
{ // Looping Anim, so let it live forever!
Life=-1;
}
else
{
Life=MaxFrame;
}
Gravity=0;
}
/*****************************************************************************/
void CFXBaseAnim::shutdown()
{
CFX::shutdown();
}
/*****************************************************************************/
/*** Think *******************************************************************/
/*****************************************************************************/
void CFXBaseAnim::think(int _frames)
{
CFX::think(_frames);
CurrentFrame+=_frames;
if (CurrentFrame>=MaxFrame)
{
CurrentFrame=0;
}
Pos.vx+=DataPtr->Velocity.vx;
Pos.vy+=DataPtr->Velocity.vy+Gravity;
if (DataPtr->Flags & FXANIM_FLAG_HAS_GRAVITY)
{
Gravity++;
}
if (DataPtr->Flags & FXANIM_FLAG_COLLIDE_KILL)
{
CLayerCollision *ColLayer=CGameScene::getCollision();
int DistY = ColLayer->getHeightFromGround( Pos.vx, Pos.vy, 16 );
if (DistY<=0)
{
Pos.vy-=DistY;
killFX();
}
}
}
/*****************************************************************************/
void CFXBaseAnim::killFX()
{
setToShutdown();
// If has follow on effect, create it now
if (DataPtr->EndFX)
{
CFX::Create((CFX::FX_TYPE)DataPtr->EndFX,getPos());
}
}
/*****************************************************************************/
/*****************************************************************************/
/*** Render ******************************************************************/
/*****************************************************************************/
void CFXBaseAnim::render()
{
DVECTOR RenderPos;
getFXRenderPos(RenderPos);
if (!canRender()) return;
SpriteBank *SprBank=CGameScene::getSpriteBank();
int ThisFrame=CurrentFrame>>DataPtr->FrameShift;
POLY_FT4 *Ft4=SprBank->printFT4Scaled(DataPtr->StartFrame+ThisFrame,RenderPos.vx,RenderPos.vy,0,0,OtPos*0,CurrentScale>>4);
Ft4->u1--; Ft4->u3--;
Ft4->v2--; Ft4->v3--;
setShadeTex(Ft4,0);
setRGB0(Ft4,DataPtr->R,DataPtr->G,DataPtr->B);
}

50
source/fx/fxbubble.h Normal file
View File

@ -0,0 +1,50 @@
/***********************/
/*** Anim Base Class ***/
/***********************/
#ifndef __FX_FX_BASE_ANIM_HEADER__
#define __FX_FX_BASE_ANIM_HEADER__
#include "fx/fx.h"
/*****************************************************************************/
class CFXBaseAnim : public CFX
{
public:
struct sFXAnim
{
s16 Scale;
s16 StartFrame,EndFrame;
s16 FrameShift;
u8 R,G,B;
u8 Flags;
DVECTOR Velocity;
u16 EndFX;
};
enum FXAnim_Flags
{
FXANIM_FLAG_LOOP =1<<0,
FXANIM_FLAG_COLLIDE_KILL =1<<1,
FXANIM_FLAG_HAS_GRAVITY =1<<2,
};
virtual void init(DVECTOR const &Pos);
virtual void shutdown();
virtual void think(int _frames);
virtual void render();
virtual void killFX();
void setData(void *Data) {DataPtr=(sFXAnim*)Data;}
virtual void SetScale(int S) {CurrentScale=S;}
protected:
sFXAnim *DataPtr;
s16 Gravity;
s16 MaxFrame;
s16 CurrentFrame;
s16 CurrentScale;
};
#endif