SBSPSS/source/fx/fxbasetrail.cpp

97 lines
2.5 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;
DieOut=0;
}
/*****************************************************************************/
2001-05-23 22:00:25 +02:00
void CFXBaseTrail::shutdown()
2001-05-23 21:28:42 +02:00
{
CFX::shutdown();
}
/*****************************************************************************/
/*** Think *******************************************************************/
/*****************************************************************************/
2001-05-23 22:00:25 +02:00
void CFXBaseTrail::think(int _frames)
2001-05-23 21:28:42 +02:00
{
CThing *Parent=getParent();
if (Parent)
{
this->setPos(Parent->getPos());
}
}
/*****************************************************************************/
2001-05-23 22:00:25 +02:00
CFXBaseTrail::sList &CFXBaseTrail::moveHead()
2001-05-23 21:28:42 +02:00
{
HeadIdx--;
if (HeadIdx<0) HeadIdx+=LIST_SIZE;
if (ListCount<LIST_SIZE) ListCount++;
return(List[HeadIdx]);
}
/*****************************************************************************/
/*** Render ******************************************************************/
/*****************************************************************************/
2001-05-23 22:00:25 +02:00
void CFXBaseTrail::render()
2001-05-23 21:28:42 +02:00
{
CFX::render();
if (canRender())
{
DVECTOR RenderPos=getRenderPos();
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-05-25 20:43:47 +02:00
Ft4=SprBank->printRotatedScaledSprite(ThisElem.Frame,RenderPos.vx,RenderPos.vy,ThisElem.Scale,ThisElem.Scale,ThisElem.Angle,OtPos*0);
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);
}
}