SBSPSS/source/fx/fxbasetrail.cpp

95 lines
2.4 KiB
C++
Raw Normal View History

2001-05-23 21:28:42 +02:00
/************************/
/*** 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"
2001-05-25 20:43:47 +02:00
#include "game\game.h"
2001-05-23 21:28:42 +02:00
2001-05-23 22:00:25 +02:00
#include "FX\FXBaseTrail.h"
2001-05-23 21:28:42 +02:00
/*****************************************************************************/
/*****************************************************************************/
/*****************************************************************************/
2001-05-23 22:00:25 +02:00
void CFXBaseTrail::init(DVECTOR const &_Pos)
2001-05-23 21:28:42 +02:00
{
CFX::init();
Pos=_Pos;
HeadIdx=0;
ListCount=0;
}
/*****************************************************************************/
/*** Think *******************************************************************/
/*****************************************************************************/
2001-05-23 22:00:25 +02:00
void CFXBaseTrail::think(int _frames)
2001-05-23 21:28:42 +02:00
{
2001-05-31 22:07:48 +02:00
DVECTOR Pos;
bool hasParent=getFXParentPos(Pos);
2001-05-23 21:28:42 +02:00
2001-05-31 22:07:48 +02:00
if (hasParent)
2001-05-23 21:28:42 +02:00
{
2001-05-31 22:07:48 +02:00
setPos(Pos);
2001-05-23 21:28:42 +02:00
}
}
/*****************************************************************************/
2001-05-23 22:00:25 +02:00
CFXBaseTrail::sList &CFXBaseTrail::moveHead()
2001-05-23 21:28:42 +02:00
{
2001-06-19 23:58:32 +02:00
if ( !( Flags & FX_FLAG_HIDDEN ) )
2001-06-06 15:27:46 +02:00
{
HeadIdx--;
if (HeadIdx<0) HeadIdx+=LIST_SIZE;
if (ListCount<LIST_SIZE) ListCount++;
}
2001-05-23 21:28:42 +02:00
return(List[HeadIdx]);
}
/*****************************************************************************/
/*** Render ******************************************************************/
/*****************************************************************************/
2001-05-23 22:00:25 +02:00
void CFXBaseTrail::render()
2001-05-23 21:28:42 +02:00
{
2001-05-31 22:07:48 +02:00
DVECTOR RenderPos;
getFXRenderPos(RenderPos);
2001-05-23 21:28:42 +02:00
if (canRender())
{
2001-05-25 20:43:47 +02:00
SpriteBank *SprBank=CGameScene::getSpriteBank();
2001-05-23 21:28:42 +02:00
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)
{
2001-06-11 22:36:53 +02:00
Ft4=SprBank->printRotatedScaledSprite(ThisElem.Frame,RenderPos.vx,RenderPos.vy,ThisElem.Scale,ThisElem.Scale,ThisElem.Angle,OtPos);
2001-05-23 21:28:42 +02:00
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);
}
}