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-05-23 22:00:25 +02:00
|
|
|
#include "FX\FXBaseAnim.h"
|
2001-05-23 21:28:42 +02:00
|
|
|
|
2001-06-07 18:33:19 +02:00
|
|
|
#ifndef __PLAYER_PLAYER_H__
|
|
|
|
#include "player\player.h"
|
|
|
|
#endif
|
|
|
|
|
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-04 21:01:17 +02:00
|
|
|
CurrentScaleX=CurrentScaleY=DataPtr->Scale;
|
|
|
|
CurrentHeading = 0;
|
2001-06-01 00:02:07 +02:00
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
2001-06-01 17:10:05 +02:00
|
|
|
VelY=0;
|
|
|
|
renderFrame=DataPtr->StartFrame;
|
2001-05-23 21:28:42 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
2001-05-23 22:00:25 +02:00
|
|
|
void CFXBaseAnim::shutdown()
|
2001-05-23 21:28:42 +02:00
|
|
|
{
|
|
|
|
CFX::shutdown();
|
|
|
|
}
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
/*** Think *******************************************************************/
|
|
|
|
/*****************************************************************************/
|
2001-05-23 22:00:25 +02:00
|
|
|
void CFXBaseAnim::think(int _frames)
|
2001-05-23 21:28:42 +02:00
|
|
|
{
|
|
|
|
CFX::think(_frames);
|
2001-05-31 22:07:48 +02:00
|
|
|
CurrentFrame+=_frames;
|
2001-06-01 00:02:07 +02:00
|
|
|
|
|
|
|
if (CurrentFrame>=MaxFrame)
|
|
|
|
{
|
|
|
|
CurrentFrame=0;
|
|
|
|
}
|
|
|
|
Pos.vx+=DataPtr->Velocity.vx;
|
2001-06-01 17:10:05 +02:00
|
|
|
Pos.vy+=DataPtr->Velocity.vy+VelY;
|
|
|
|
|
|
|
|
int ThisFrame=CurrentFrame>>DataPtr->FrameShift;
|
|
|
|
renderFrame=DataPtr->StartFrame+ThisFrame;
|
2001-06-01 00:02:07 +02:00
|
|
|
|
|
|
|
if (DataPtr->Flags & FXANIM_FLAG_HAS_GRAVITY)
|
|
|
|
{
|
2001-06-01 17:10:05 +02:00
|
|
|
VelY++;
|
2001-06-01 00:02:07 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
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();
|
|
|
|
}
|
|
|
|
}
|
2001-05-23 21:28:42 +02:00
|
|
|
}
|
|
|
|
|
2001-06-01 00:02:07 +02:00
|
|
|
/*****************************************************************************/
|
|
|
|
void CFXBaseAnim::killFX()
|
|
|
|
{
|
|
|
|
setToShutdown();
|
|
|
|
// If has follow on effect, create it now
|
|
|
|
if (DataPtr->EndFX)
|
|
|
|
{
|
|
|
|
CFX::Create((CFX::FX_TYPE)DataPtr->EndFX,getPos());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
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-05-31 22:07:48 +02:00
|
|
|
DVECTOR RenderPos;
|
|
|
|
|
|
|
|
getFXRenderPos(RenderPos);
|
2001-06-01 23:00:15 +02:00
|
|
|
if (!canRender() || !IsVisible) 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);
|
|
|
|
setRGB0(Ft4,DataPtr->R,DataPtr->G,DataPtr->B);
|
2001-06-11 22:36:53 +02:00
|
|
|
setSemiTrans(Ft4,DataPtr->Flags & FXANIM_FLAG_TRANS);
|
2001-05-23 21:28:42 +02:00
|
|
|
}
|
2001-06-07 18:33:19 +02:00
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
void CFXBaseAnim::collidedWith(CThing *_thisThing)
|
|
|
|
{
|
|
|
|
switch(_thisThing->getThingType())
|
|
|
|
{
|
|
|
|
case TYPE_PLAYER:
|
|
|
|
{
|
|
|
|
CPlayer *player = (CPlayer *) _thisThing;
|
|
|
|
|
|
|
|
if ( !player->isRecoveringFromHit() )
|
|
|
|
{
|
|
|
|
if ( DataPtr->Flags & FXANIM_FLAG_KILL_PLAYER )
|
|
|
|
{
|
|
|
|
player->takeDamage( DAMAGE__KILL_OUTRIGHT );
|
|
|
|
}
|
|
|
|
else if ( DataPtr->Flags & FXANIM_FLAG_INJURE_PLAYER )
|
|
|
|
{
|
|
|
|
player->takeDamage( DAMAGE__HIT_ENEMY );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|