This commit is contained in:
Daveo 2001-05-23 19:28:42 +00:00
parent c2acc2910e
commit 4efbe15f51
4 changed files with 237 additions and 0 deletions

71
source/fx/fxbaseanim.cpp Normal file
View File

@ -0,0 +1,71 @@
/***********************/
/*** 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 "FX\FXAnim.h"
/*****************************************************************************/
/*****************************************************************************/
/*****************************************************************************/
void CFXAnim::init(DVECTOR const &_Pos)
{
CFX::init();
Pos=_Pos;
SetFrame(0,0);
Scale=ONE;
}
/*****************************************************************************/
void CFXAnim::shutdown()
{
CFX::shutdown();
}
/*****************************************************************************/
void CFXAnim::SetFrame(int Base,int Count,int Shift=0)
{
Frame=0;
BaseFrame=Base;
FrameShift=Shift;
MaxFrame=(Count<<FrameShift)-1;
}
/*****************************************************************************/
/*** Think *******************************************************************/
/*****************************************************************************/
void CFXAnim::think(int _frames)
{
CFX::think(_frames);
Frame+=_frames;
if (Frame>=MaxFrame) setToShutdown();
}
/*****************************************************************************/
/*** Render ******************************************************************/
/*****************************************************************************/
void CFXAnim::render()
{
CFX::render();
if (!canRender() || isSetToShutdown()) return;
DVECTOR &RenderPos=getRenderPos();
POLY_FT4 *Ft4;
int ThisFrame=(MaxFrame-Frame)>>FrameShift;
printf("%i\n",ThisFrame);
Ft4=m_spriteBank->printRotatedScaledSprite(BaseFrame+ThisFrame,RenderPos.vx,RenderPos.vy,Scale,Scale,0,OtPos*0);
setRGB0(Ft4,R,G,B);
}

31
source/fx/fxbaseanim.h Normal file
View File

@ -0,0 +1,31 @@
/***********************/
/*** Anim Base Class ***/
/***********************/
#ifndef __FX_FX_ANIM_HEADER__
#define __FX_FX_ANIM_HEADER__
#include "fx/fx.h"
/*****************************************************************************/
class CFXAnim : public CFX
{
public:
virtual void init(DVECTOR const &Pos);
virtual void shutdown();
virtual void think(int _frames);
virtual void render();
virtual void SetScale(int S) {Scale=S;}
virtual void SetFrame(int Base,int Count,int Shift=0);
protected:
s16 BaseFrame,Frame;
s16 MaxFrame;
s16 FrameShift;
s16 Scale;
u8 R,G,B;
};
#endif

95
source/fx/fxbasetrail.cpp Normal file
View File

@ -0,0 +1,95 @@
/************************/
/*** Trail 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 "FX\FXTrail.h"
/*****************************************************************************/
/*****************************************************************************/
/*****************************************************************************/
void CFXTrail::init(DVECTOR const &_Pos)
{
CFX::init();
Pos=_Pos;
HeadIdx=0;
ListCount=0;
DieOut=0;
}
/*****************************************************************************/
void CFXTrail::shutdown()
{
CFX::shutdown();
}
/*****************************************************************************/
/*** Think *******************************************************************/
/*****************************************************************************/
void CFXTrail::think(int _frames)
{
CThing *Parent=getParent();
if (Parent)
{
this->setPos(Parent->getPos());
}
}
/*****************************************************************************/
CFXTrail::sList &CFXTrail::moveHead()
{
HeadIdx--;
if (HeadIdx<0) HeadIdx+=LIST_SIZE;
if (ListCount<LIST_SIZE) ListCount++;
return(List[HeadIdx]);
}
/*****************************************************************************/
/*** Render ******************************************************************/
/*****************************************************************************/
void CFXTrail::render()
{
CFX::render();
if (canRender())
{
DVECTOR RenderPos=getRenderPos();
int ThisIdx=HeadIdx;
int StartY=RenderPos.vy;
for (int i=0; i<ListCount; i++)
{
sList &ThisElem=List[ThisIdx];
POLY_FT4 *Ft4;
RenderPos.vx+=ThisElem.Ofs.vx>>2;
RenderPos.vy+=ThisElem.Ofs.vy>>2;
if (ThisElem.Shade)
{
Ft4=m_spriteBank->printRotatedScaledSprite(ThisElem.Frame,RenderPos.vx,RenderPos.vy,ThisElem.Scale,ThisElem.Scale,ThisElem.Angle,OtPos*0);
setShadeTex(Ft4,0);
setRGB0(Ft4,ThisElem.Shade,ThisElem.Shade,ThisElem.Shade);
setSemiTrans(Ft4,1);
Ft4->tpage|=Trans<<5;
}
ThisIdx++;
ThisIdx&=LIST_SIZE-1;
}
int BY=(RenderPos.vy-StartY)-32;
setCollisionCentreOffset(0,BY>>1);
setCollisionSize(64,-BY);
}
}

40
source/fx/fxbasetrail.h Normal file
View File

@ -0,0 +1,40 @@
/***********************/
/*** Trail Base Class ***/
/***********************/
#ifndef __FX_FX_TRAIL_HEADER__
#define __FX_FX_TRAIL_HEADER__
#include "fx/fx.h"
/*****************************************************************************/
class CFXTrail : public CFX
{
public:
struct sList
{
u16 Frame;
u16 Scale,Angle;
DVECTOR Ofs,Vel;
s16 Shade; // Acts as life
};
enum
{
LIST_SIZE = 16
};
virtual void init(DVECTOR const &Pos);
virtual void shutdown();
virtual void think(int _frames);
virtual void render();
virtual sList &moveHead();
protected:
sList List[LIST_SIZE];
s16 ListCount;
s16 HeadIdx;
u16 Trans;
};
#endif