SBSPSS/source/fx/fx.cpp

410 lines
8.4 KiB
C++
Raw Normal View History

2001-05-05 20:12:30 +02:00
/*********************/
/*** FX 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-09 21:57:57 +02:00
#include "gfx\otpos.h"
2001-05-05 20:12:30 +02:00
#include "FX\FX.h"
#include "FX\FXjfish.h"
2001-05-23 22:00:25 +02:00
#include "FX\FXBaseTrail.h"
#include "FX\FXBaseAnim.h"
2001-05-31 22:07:48 +02:00
#include "FX\FXBaseEmitter.h"
2001-06-01 17:10:05 +02:00
#include "FX\FXBubble.h"
2001-05-16 21:06:02 +02:00
#include "FX\FXfallingTile.h"
2001-05-18 22:54:43 +02:00
#include "FX\FXSteam.h"
2001-05-05 20:12:30 +02:00
2001-05-31 22:07:48 +02:00
#include "FX\FXNrgBar.h"
2001-05-05 20:12:30 +02:00
2001-05-31 22:07:48 +02:00
/*****************************************************************************/
/*****************************************************************************/
/*****************************************************************************/
// Anim Data
2001-06-01 00:02:07 +02:00
CFXBaseAnim::sFXAnim FXWaterSplashData=
2001-05-31 22:07:48 +02:00
{
ONE,
FRM__SPLASH001,FRM__SPLASH006,
1,
2001-06-01 00:02:07 +02:00
127,127,255,
0,
{0,0},
0,
2001-05-31 22:07:48 +02:00
};
2001-05-05 20:12:30 +02:00
2001-06-01 00:02:07 +02:00
CFXBaseAnim::sFXAnim FXAcidSplashData=
2001-05-31 22:07:48 +02:00
{
ONE,
FRM__SPLASH001,FRM__SPLASH006,
1,
2001-06-01 00:02:07 +02:00
0,255,0,
0,
{0,0},
0
2001-05-31 22:07:48 +02:00
};
2001-06-01 00:02:07 +02:00
CFXBaseAnim::sFXAnim FXLavaSplashData=
2001-05-31 22:07:48 +02:00
{
ONE,
FRM__SPLASH001,FRM__SPLASH006,
1,
2001-06-01 00:02:07 +02:00
255,0,0,
0,
{0,0},
0
2001-05-31 22:07:48 +02:00
};
2001-06-01 00:02:07 +02:00
CFXBaseAnim::sFXAnim FXOilSplashData=
2001-05-31 22:07:48 +02:00
{
ONE,
FRM__SPLASH001,FRM__SPLASH006,
1,
2001-06-01 00:02:07 +02:00
0,0,0,
0,
{0,0},
CFX::FX_TYPE_EXPLODE,
2001-05-31 22:07:48 +02:00
};
2001-05-05 20:12:30 +02:00
2001-06-01 00:02:07 +02:00
CFXBaseAnim::sFXAnim FXExplodeData=
2001-05-31 22:07:48 +02:00
{
ONE,
FRM__EXPLOSION0001,FRM__EXPLOSION0006,
1,
2001-06-01 00:02:07 +02:00
127,127,127,
0,
{0,0},
0
};
CFXBaseAnim::sFXAnim FXFireData=
{
2001-06-04 16:09:05 +02:00
ONE << 1,
2001-06-01 00:02:07 +02:00
FRM__FIRE01,FRM__FIRE06,
1,
127,127,127,
CFXBaseAnim::FXANIM_FLAG_LOOP,
{0,0},
0
};
CFXBaseAnim::sFXAnim FXWaterDripData=
{
ONE,
FRM__DRIP,FRM__DRIP,
1,
127,127,255,
CFXBaseAnim::FXANIM_FLAG_LOOP | CFXBaseAnim::FXANIM_FLAG_COLLIDE_KILL | CFXBaseAnim::FXANIM_FLAG_HAS_GRAVITY,
{0,1},
CFX::FX_TYPE_SPLASH_WATER
};
CFXBaseAnim::sFXAnim FXAcidDripData=
{
ONE,
FRM__DRIP,FRM__DRIP,
1,
127,127,255,
2001-06-01 17:10:05 +02:00
CFXBaseAnim::FXANIM_FLAG_LOOP | CFXBaseAnim::FXANIM_FLAG_COLLIDE_KILL | CFXBaseAnim::FXANIM_FLAG_HAS_GRAVITY,
2001-06-01 00:02:07 +02:00
{0,1},
CFX::FX_TYPE_SPLASH_WATER
};
CFXBaseAnim::sFXAnim FXLavaDripData=
{
ONE,
FRM__DRIP,FRM__DRIP,
1,
127,127,255,
2001-06-01 17:10:05 +02:00
CFXBaseAnim::FXANIM_FLAG_LOOP | CFXBaseAnim::FXANIM_FLAG_COLLIDE_KILL | CFXBaseAnim::FXANIM_FLAG_HAS_GRAVITY,
2001-06-01 00:02:07 +02:00
{0,1},
CFX::FX_TYPE_SPLASH_WATER
};
CFXBaseAnim::sFXAnim FXOilDripData=
{
ONE,
FRM__DRIP,FRM__DRIP,
1,
127,127,255,
2001-06-01 17:10:05 +02:00
CFXBaseAnim::FXANIM_FLAG_LOOP | CFXBaseAnim::FXANIM_FLAG_COLLIDE_KILL | CFXBaseAnim::FXANIM_FLAG_HAS_GRAVITY,
2001-06-01 00:02:07 +02:00
{0,1},
CFX::FX_TYPE_SPLASH_WATER
2001-05-31 22:07:48 +02:00
};
2001-06-01 17:10:05 +02:00
// Bubble
CFXBaseAnim::sFXAnim FXBubbleWaterData=
{
ONE/2,
FRM__BUBBLE_2,FRM__BUBBLE_2,
1,
127,127,255,
CFXBaseAnim::FXANIM_FLAG_LOOP | CFXBaseAnim::FXANIM_FLAG_COLLIDE_KILL,
{0,-1},
CFX::FX_TYPE_SPLASH_WATER
};
CFXBaseAnim::sFXAnim FXBubbleAcidData=
{
ONE/2,
FRM__BUBBLE_2,FRM__BUBBLE_2,
1,
127,127,255,
CFXBaseAnim::FXANIM_FLAG_LOOP | CFXBaseAnim::FXANIM_FLAG_COLLIDE_KILL,
{0,-1},
CFX::FX_TYPE_SPLASH_WATER
};
CFXBaseAnim::sFXAnim FXBubbleLavaData=
{
ONE/2,
FRM__BUBBLE_2,FRM__BUBBLE_2,
1,
127,127,255,
CFXBaseAnim::FXANIM_FLAG_LOOP | CFXBaseAnim::FXANIM_FLAG_COLLIDE_KILL,
{0,-1},
CFX::FX_TYPE_SPLASH_WATER
};
CFXBaseAnim::sFXAnim FXBubbleOilData=
{
ONE/2,
FRM__BUBBLE_2,FRM__BUBBLE_2,
1,
127,127,255,
CFXBaseAnim::FXANIM_FLAG_LOOP | CFXBaseAnim::FXANIM_FLAG_COLLIDE_KILL,
{0,-1},
CFX::FX_TYPE_SPLASH_WATER
};
2001-05-23 21:27:05 +02:00
2001-05-21 20:11:30 +02:00
/*****************************************************************************/
2001-05-23 21:27:05 +02:00
/*
2001-05-21 20:11:30 +02:00
CFXSteam *TestFXPtr=0;
void TestFX(DVECTOR Pos)
{
if (!TestFXPtr)
{
2001-05-31 22:07:48 +02:00
Pos.vx=256;
Pos.vy=128;
2001-05-21 20:11:30 +02:00
TestFXPtr=(CFXSteam*)CFX::Create(CFX::FX_TYPE_STEAM,Pos);
2001-05-23 00:30:36 +02:00
TestFXPtr->setLife(32);
2001-05-31 22:07:48 +02:00
TestFXPtr->setRelativeToMap(false);
2001-05-23 00:30:36 +02:00
TestFXPtr=0;
2001-05-21 20:11:30 +02:00
}
else
{
2001-05-31 22:07:48 +02:00
TestFXPtr->killFX();
2001-05-21 20:11:30 +02:00
TestFXPtr=0;
}
}
2001-05-23 21:27:05 +02:00
*/
/*****************************************************************************/
2001-06-01 17:10:05 +02:00
int FXType=(CFX::FX_TYPE)CFX::FX_TYPE_BUBBLE_WATER;
2001-05-23 21:27:05 +02:00
void TestFX(DVECTOR Pos)
{
2001-05-31 22:07:48 +02:00
CFX::Create((CFX::FX_TYPE)FXType,Pos);
2001-05-23 21:27:05 +02:00
// TestFXPtr->setLife(32);
}
2001-05-21 20:11:30 +02:00
2001-05-05 20:12:30 +02:00
/*****************************************************************************/
2001-05-16 21:06:02 +02:00
CFX *CFX::Create(const FX_TYPE Type)
2001-05-05 20:12:30 +02:00
{
CFX *NewFX;
2001-05-25 20:43:47 +02:00
NewFX = (CFX*)CThingManager::GetThing(CThing::TYPE_FX,Type);
if (!NewFX)
2001-05-05 20:12:30 +02:00
switch(Type)
{
2001-05-16 21:06:02 +02:00
case FX_TYPE_FALLINGTILE:
2001-05-23 21:27:05 +02:00
NewFX=new ("FXFalling Tile") CFXFallingTile();
2001-05-16 21:06:02 +02:00
break;
2001-05-21 20:11:30 +02:00
case FX_TYPE_STEAM:
2001-05-23 21:27:05 +02:00
NewFX=new ("FXSteam") CFXSteam();
break;
2001-05-23 22:43:32 +02:00
case FX_TYPE_SPLASH_WATER:
2001-05-31 22:07:48 +02:00
NewFX=new ("FXWaterSplash") CFXBaseAnim();
NewFX->setData(&FXWaterSplashData);
2001-05-23 22:43:32 +02:00
break;
case FX_TYPE_SPLASH_ACID:
2001-05-31 22:07:48 +02:00
NewFX=new ("FXAcidSplash") CFXBaseAnim();
NewFX->setData(&FXAcidSplashData);
2001-05-23 22:43:32 +02:00
break;
case FX_TYPE_SPLASH_LAVA:
2001-05-31 22:07:48 +02:00
NewFX=new ("FXLavaSplash") CFXBaseAnim();
NewFX->setData(&FXLavaSplashData);
2001-05-23 22:43:32 +02:00
break;
case FX_TYPE_SPLASH_OIL:
2001-05-31 22:07:48 +02:00
NewFX=new ("FXOilSplash") CFXBaseAnim();
NewFX->setData(&FXOilSplashData);
2001-05-23 22:43:32 +02:00
break;
case FX_TYPE_EXPLODE:
2001-05-31 22:07:48 +02:00
NewFX=new ("FXExplode") CFXBaseAnim();
NewFX->setData(&FXExplodeData);
2001-05-23 22:43:32 +02:00
break;
2001-06-01 00:02:07 +02:00
case FX_TYPE_FLAMES:
NewFX=new ("FXFlames") CFXBaseAnim();
NewFX->setData(&FXFireData);
break;
case FX_TYPE_DROP_WATER:
NewFX=new ("FXWaterDrip") CFXBaseAnim();
NewFX->setData(&FXWaterDripData);
break;
case FX_TYPE_DROP_ACID:
NewFX=new ("FXAcidDrip") CFXBaseAnim();
NewFX->setData(&FXAcidDripData);
break;
case FX_TYPE_DROP_LAVA:
NewFX=new ("FXLavaDrip") CFXBaseAnim();
NewFX->setData(&FXLavaDripData);
break;
case FX_TYPE_DROP_OIL:
NewFX=new ("FXOilDrip") CFXBaseAnim();
NewFX->setData(&FXOilDripData);
break;
2001-06-01 17:10:05 +02:00
case FX_TYPE_BUBBLE_WATER:
NewFX=new ("FXBubbleWater") CFXBubble();
NewFX->setData(&FXBubbleWaterData);
break;
case FX_TYPE_BUBBLE_ACID:
NewFX=new ("FXBubbleAcid") CFXBubble();
NewFX->setData(&FXBubbleAcidData);
break;
case FX_TYPE_BUBBLE_LAVA:
NewFX=new ("FXBubbleLava") CFXBubble();
NewFX->setData(&FXBubbleLavaData);
break;
case FX_TYPE_BUBBLE_OIL:
NewFX=new ("FXBubbleOil") CFXBubble();
NewFX->setData(&FXBubbleOilData);
break;
2001-05-23 22:43:32 +02:00
2001-05-31 00:05:41 +02:00
case FX_TYPE_NRG_BAR:
NewFX=new ("NRG Bar") CFXNRGBar();
break;
2001-05-18 22:54:43 +02:00
case FX_TYPE_JELLYFISH_LEGS:
2001-05-30 22:36:44 +02:00
NewFX=new ("JellyFish Legs") CFXJellyFishLegs();
break;
2001-05-05 20:12:30 +02:00
case FX_TYPE_LIGHTNING_BOLT:
case FX_TYPE_LIGHTNING_SHEET:
case FX_TYPE_LIGHTNING_BLAST:
case FX_TYPE_LIGHTNING_RADIAL:
case FX_TYPE_LIGHTNING_PROJECTILE:
case FX_TYPE_SHOCKWAVE:
case FX_TYPE_DAZE:
2001-05-31 22:07:48 +02:00
2001-05-05 20:12:30 +02:00
case FX_TYPE_CASCADE:
case FX_TYPE_CASCADE_SPLASH:
case FX_TYPE_FIREBALL:
2001-05-31 22:07:48 +02:00
case FX_TYPE_SMOKE:
case FX_TYPE_GAS:
2001-05-05 20:12:30 +02:00
default:
ASSERT(!"UNKNOWN FX TYPE");
return NULL;
}
2001-05-25 20:43:47 +02:00
NewFX->setThingSubType(Type);
2001-05-16 21:06:02 +02:00
return NewFX;
}
2001-05-05 20:12:30 +02:00
2001-05-16 21:06:02 +02:00
/*****************************************************************************/
CFX *CFX::Create(const FX_TYPE Type,CThing *Parent)
{
CFX *NewFX=CFX::Create(Type);
2001-05-15 23:36:31 +02:00
2001-05-18 22:54:43 +02:00
NewFX->init(Parent->getPos());
2001-05-30 22:36:44 +02:00
ASSERT(Parent);
2001-05-18 22:54:43 +02:00
Parent->addChild(NewFX);
2001-05-16 21:06:02 +02:00
return NewFX;
}
/*****************************************************************************/
CFX *CFX::Create(const FX_TYPE Type,DVECTOR const &Pos)
{
CFX *NewFX=CFX::Create(Type);
NewFX->init(Pos);
return NewFX;
2001-05-05 20:12:30 +02:00
}
/*****************************************************************************/
/*****************************************************************************/
/*****************************************************************************/
void CFX::init()
{
2001-05-09 21:57:57 +02:00
CFXThing::init();
OtPos=OTPOS__ACTOR_POS;
2001-05-31 22:07:48 +02:00
RelativeToMap=true;
Life=-1; // Set to immortal
2001-06-01 23:00:15 +02:00
IsVisible=true;
2001-05-31 22:07:48 +02:00
}
2001-05-23 00:30:36 +02:00
2001-05-31 22:07:48 +02:00
/*****************************************************************************/
void CFX::init(DVECTOR const &_Pos)
{
init();
Pos=_Pos;
2001-05-05 20:12:30 +02:00
}
/*****************************************************************************/
void CFX::shutdown()
{
2001-05-15 23:36:31 +02:00
CFXThing::shutdown();
2001-05-05 20:12:30 +02:00
}
/*****************************************************************************/
void CFX::think(int _frames)
{
CFXThing::think(_frames);
2001-05-31 22:07:48 +02:00
2001-05-23 00:30:36 +02:00
if (Life>0)
{
2001-05-31 22:07:48 +02:00
Life-=_frames;
if (Life<=0)
2001-05-23 00:30:36 +02:00
{
2001-05-31 22:07:48 +02:00
killFX();
2001-05-23 00:30:36 +02:00
}
}
2001-05-05 20:12:30 +02:00
}
/*****************************************************************************/
void CFX::render()
{
2001-05-16 21:06:02 +02:00
CFXThing::render();
2001-05-05 20:12:30 +02:00
}
2001-05-31 22:07:48 +02:00
/*****************************************************************************/
bool CFX::getFXParentPos(DVECTOR &Pos)
{
CThing *Parent=getParent();
if (!Parent) return(false);
if (RelativeToMap)
{
Pos=Parent->getPos();
}
else
{
Pos=getPos();
}
return(true);
}
/*****************************************************************************/
void CFX::getFXRenderPos(DVECTOR &Pos)
{
if (RelativeToMap)
{
CFX::render();
Pos=getRenderPos();
}
else
{
Pos=getPos();
}
}