This commit is contained in:
Daveo 2001-07-02 19:29:20 +00:00
parent a8fee4fc4b
commit a7322aa222
11 changed files with 197 additions and 251 deletions

View File

@ -177,6 +177,8 @@ fx_src := fx \
fxfallingtile \
fxsteam \
fxlaser \
fxsmoke \
fxtvexplode \
fxgeyser
projectl_src := projectl \

View File

@ -159,11 +159,12 @@ cleanactors :
SFX_GFX_DIR := $(GRAF_DIR)/sfx
SFX_GFX := +smoke.bmp \
+explosion0001.bmp +explosion0002.bmp +explosion0003.bmp +explosion0004.bmp +explosion0005.bmp +explosion0006.bmp \
+explosion0001.bmp +explosion0002.bmp +explosion0003.bmp +explosion0004.bmp +explosion0005.bmp +explosion0006.bmp +explosion0007.bmp +explosion0008.bmp\
+splash001.bmp +splash002.bmp +splash003.bmp +splash004.bmp +splash005.bmp +splash006.bmp \
+fire01.bmp +fire02.bmp +fire03.bmp +fire04.bmp +fire05.bmp +fire06.bmp +fire07.bmp +fire08.bmp\
+drip.bmp +bubblepop.bmp \
+Gush000.bmp +Gush001.bmp +Gush002.bmp +Gush003.bmp +GushBase.bmp \
+cog01.bmp +elecvalve.bmp\
+leg.bmp +thwack.bmp +lightning1.bmp +lightning2.bmp
SFX_GFX_IN := $(foreach FILE,$(SFX_GFX),$(SFX_GFX_DIR)/$(FILE))

View File

@ -26,8 +26,10 @@
#include "FX\FXfallingTile.h"
#include "FX\FXSteam.h"
#include "FX\FXGeyser.h"
#include "FX\FXSmoke.h"
#include "FX\FXNrgBar.h"
#include "FX\FXTVExplode.h"
/*****************************************************************************/
/*****************************************************************************/
@ -59,7 +61,7 @@ CFXBaseAnim::sFXBaseData FXSplashBaseData=
CFXBaseAnim::sFXBaseData FXExplodeBaseData=
{
FRM__EXPLOSION0001,FRM__EXPLOSION0006,1,
FRM__EXPLOSION0001,FRM__EXPLOSION0008,1,
FX_FLAG_NO_THINK_KILL,
};
@ -95,12 +97,14 @@ void TestFX(DVECTOR Pos,CThing *Parent)
*/
/*****************************************************************************/
int FXType=(CFX::FX_TYPE)CFX::FX_TYPE_GEYSER_WATER;
int FXType=(CFX::FX_TYPE)CFX::FX_TYPE_TV_EXPLODE;
#include "game\game.h"
void TestFX(DVECTOR Pos,CThing *Parent)
{
Pos.vy-=16*8;
CFX::Create((CFX::FX_TYPE)FXType,Pos);
// CFX::Create((CFX::FX_TYPE)FXType,Parent);
}
@ -117,6 +121,10 @@ CFX *NewFX;
ASSERT(!"FX NONE CANT BE CREATED!");
break;
case FX_TYPE_BASE_ANIM:
NewFX=new ("FXBaseAnim") CFXBaseAnim();
break;
case FX_TYPE_DROP_WATER:
NewFX=new ("FXWaterDrip") CFXBaseAnim();
NewFX->setBaseData(&FXDropBaseData);
@ -213,9 +221,6 @@ CFX *NewFX;
case FX_TYPE_STEAM:
NewFX=new ("FXSteam") CFXSteam();
break;
case FX_TYPE_SMOKE:
ASSERT(!"FX_TYPE_SMOKE");
break;
case FX_TYPE_GAS:
ASSERT(!"FX_TYPE_GAS");
break;
@ -224,6 +229,13 @@ CFX *NewFX;
NewFX->setBaseData(&FXFireBaseData);
break;
case FX_TYPE_SMOKE:
NewFX=new ("FXSmoke") CFXSmoke();
break;
case FX_TYPE_SMOKE_PUFF:
NewFX=new ("FXSmokePuff") CFXSmokePuff();
break;
case FX_TYPE_JELLYFISH_LEGS:
NewFX=new ("JellyFish Legs") CFXJellyFishLegs();
break;
@ -240,6 +252,9 @@ CFX *NewFX;
case FX_TYPE_LASER:
NewFX=new ("FX Laser") CFXLaser();
break;
case FX_TYPE_TV_EXPLODE:
NewFX=new ("FX TVExplode") CFXTVExplode();
break;
default:
ASSERT(!"UNKNOWN FX TYPE");
@ -305,6 +320,13 @@ void CFX::shutdown()
/*****************************************************************************/
void CFX::think(int _frames)
{
CThing *Parent=getParent();
if (Parent)
{
Pos=Parent->getPos();
}
CFXThing::think(_frames);
if (Life>0)
@ -323,15 +345,23 @@ void CFX::think(int _frames)
Pos.vx+=Velocity.vx;
Pos.vy+=Velocity.vy;
if (Flags & FX_FLAG_COLLIDE_KILL)
if (Flags & FX_FLAG_COLLIDE_KILL || Flags & FX_FLAG_COLLIDE_BOUNCE)
{
CLayerCollision *ColLayer=CGameScene::getCollision();
int DistY = ColLayer->getHeightFromGround( Pos.vx, Pos.vy, 16 );
if (DistY<=0)
{
Pos.vy-=DistY;
killFX();
Pos.vy+=DistY;
if (Flags & FX_FLAG_COLLIDE_KILL)
{
killFX();
}
else
{
Velocity.vx/=2;
Velocity.vy=-Velocity.vy>>1;
}
}
}

View File

@ -15,6 +15,7 @@ enum FX_FLAG
FX_FLAG_HAS_GRAVITY =1<<2,
FX_FLAG_INJURE_PLAYER =1<<3,
FX_FLAG_TRANS =1<<4,
FX_FLAG_COLLIDE_BOUNCE =1<<5,
FX_FLAG_NO_THINK_KILL =1<<13,
FX_FLAG_HIDDEN =1<<14,
@ -28,6 +29,8 @@ public:
{
FX_TYPE_NONE=0,
FX_TYPE_BASE_ANIM,
FX_TYPE_DROP_WATER,
FX_TYPE_DROP_ACID,
FX_TYPE_DROP_LAVA,
@ -52,15 +55,19 @@ public:
FX_TYPE_LIGHTNING_BOLT,
FX_TYPE_STEAM,
FX_TYPE_SMOKE,
FX_TYPE_GAS,
FX_TYPE_FLAMES,
FX_TYPE_SMOKE,
FX_TYPE_SMOKE_PUFF,
FX_TYPE_JELLYFISH_LEGS,
FX_TYPE_FALLINGTILE,
FX_TYPE_EXPLODE,
FX_TYPE_NRG_BAR,
FX_TYPE_LASER,
FX_TYPE_TV_EXPLODE,
FX_TYPE_MAX
};
enum
@ -123,6 +130,8 @@ public:
void setRGB(FX_RGB T) {setRGB(FXRGBTable[T]);}
void setAfterEffect(FX_TYPE Type) {AfterEffect=Type;}
void setVelocity(int X,int Y) {Velocity.vx=X; Velocity.vy=Y;}
//protected:
s16 Life;
u16 Flags;

View File

@ -21,19 +21,8 @@ void CFXBaseAnim::init(DVECTOR const &_Pos)
CurrentFrame=0;
CurrentScaleX=CurrentScaleY=ONE;
CurrentHeading = 0;
HasInit=false;
MaxFrame=((BaseData->EndFrame-BaseData->StartFrame)<<BaseData->FrameShift)-1;
Flags|=BaseData->Flags;
renderFrame=BaseData->StartFrame;
if (Flags & FX_FLAG_LOOP)
{
Life=-1;
}
else
{
Life=MaxFrame;
}
}
/*****************************************************************************/
@ -48,14 +37,30 @@ void CFXBaseAnim::setBaseData(void *Data)
/*****************************************************************************/
void CFXBaseAnim::think(int _frames)
{
if (!HasInit)
{
MaxFrame=((BaseData->EndFrame-BaseData->StartFrame)<<BaseData->FrameShift)-1;
Flags|=BaseData->Flags;
renderFrame=BaseData->StartFrame;
if (Flags & FX_FLAG_LOOP)
{
Life=-1;
}
else
{
Life=MaxFrame;
}
HasInit=true;
}
CFX::think(_frames);
if (BaseData->StartFrame!=BaseData->EndFrame)
{
// CurrentFrame+=_frames;
CurrentFrame+=1;
CurrentFrame++;
if (CurrentFrame>=MaxFrame)
if (CurrentFrame>MaxFrame)
{
CurrentFrame=0;
}

View File

@ -29,7 +29,7 @@ virtual void SetScaleY(int S) {CurrentScaleY=S;}
virtual void SetHeading(int H) {CurrentHeading=H;}
protected:
bool HasInit;
sFXBaseData *BaseData;
POLY_FT4 *Frame;

View File

@ -37,7 +37,7 @@ void CFXJellyFishLegs::Setup(int XOfs,int YOfs,bool XFlip)
{
Ofs.vx=XOfs;
Ofs.vy=YOfs;
this->XFlip=XFlip;
XFlip=XFlip;
}
/*****************************************************************************/
@ -46,8 +46,6 @@ void CFXJellyFishLegs::Setup(int XOfs,int YOfs,bool XFlip)
void CFXJellyFishLegs::think(int _frames)
{
Pos=getParent()->getPos();
CFX::think(_frames);
Angle++; Angle&=CIRCLE_TAB_MASK;
AngleInc=LegAngleInc;

View File

@ -1,6 +1,6 @@
/******************/
/*** Smoke Puff ***/
/******************/
/**************/
/*** Smoke ***/
/**************/
#include "system\global.h"
#include <DStructs.h>
@ -11,22 +11,55 @@
#include "level\level.h"
#include "game\game.h"
#include "FX\FXSmokePuff.h"
#include "FX\FXSmoke.h"
int SmokePuffStartScale=ONE*2;
int SmokePuffScaleInc=128;
int SmokePuffAngleInc=128;
static const int SmokeStartRate=32;
static const int SmokePuffScaleInc=64;
static const int SmokePuffAngleInc=64;
static const int SmokePuffRGBDec=4;
/*****************************************************************************/
void CFXSmoke::init(DVECTOR const &_Pos)
{
CFX::init(_Pos);
Rate=SmokeStartRate;
CurrentRate=Rate;
}
/*****************************************************************************/
/*** Think *******************************************************************/
/*****************************************************************************/
void CFXSmoke::think(int _frames)
{
CFX::think(_frames);
Rate=SmokeStartRate;
CurrentRate+=_frames;
if (CurrentRate>=Rate)
{
CurrentRate=0;
CFXSmokePuff *FX=(CFXSmokePuff*)CFX::Create(CFX::FX_TYPE_SMOKE_PUFF,Pos);
FX->setRGB(255,255,255);
}
}
/*****************************************************************************/
/*****************************************************************************/
/*** Smoke Puff **************************************************************/
/*****************************************************************************/
/*****************************************************************************/
void CFXSmokePuff::init(DVECTOR const &_Pos)
{
CFX::init(_Pos);
Velocity.vy=-1;
CurrentAngle=0;
CurrentScale=SmokePuffStartScale;
RGBDec=255/(CurrentScale/SmokePuffScaleInc);
RGB.R=RGB.G=RGB.B=255;
CurrentAngle=getRndRange(4095);
AngleInc=SmokePuffAngleInc+getRndRange(SmokePuffAngleInc);
CurrentScale=1024;
ScaleInc=SmokePuffScaleInc+getRndRange(SmokePuffScaleInc);
setRGB(255,255,255);
}
/*****************************************************************************/
@ -36,14 +69,23 @@ void CFXSmokePuff::think(int _frames)
{
CFX::think(_frames);
CurrentScale-=SmokePuffScaleInc;
RGB.R-=RGBDec;
RGB.G-=RGBDec;
RGB.B-=RGBDec;
CurrentAngle+=SmokePuffAngleInc;
CurrentScale+=ScaleInc;
CurrentAngle+=AngleInc;
CurrentAngle&=4095;
if (CurrentScale<0)
int R=RGB.R-SmokePuffRGBDec;
int G=RGB.G-SmokePuffRGBDec;
int B=RGB.B-SmokePuffRGBDec;
if (R<0) R=0;
if (G<0) G=0;
if (B<0) B=0;
RGB.R=R;
RGB.G=G;
RGB.B=B;
if (RGB.R+RGB.G+RGB.B==0)
{
killFX();
}

View File

@ -1,13 +1,27 @@
/***********************/
/*** Anim Base Class ***/
/***********************/
/*************/
/*** Smoke ***/
/*************/
#ifndef __FX_FX_SMOKE_PUFF_HEADER__
#define __FX_FX_SMOKE_PUFF_HEADER__
#ifndef __FX_FX_SMOKE_HEADER__
#define __FX_FX_SMOKE_HEADER__
#include "fx/fx.h"
/*****************************************************************************/
class CFXSmoke : public CFX
{
public:
virtual void init(DVECTOR const &Pos);
virtual void think(int _frames);
void setRate(int R) {Rate=R;}
protected:
int Rate;
int CurrentRate;
};
class CFXSmokePuff : public CFX
{
public:
@ -19,9 +33,8 @@ virtual void render();
protected:
POLY_FT4 *Frame;
s32 CurrentScale;
s32 CurrentAngle;
s16 RGBDec;
int CurrentScale,ScaleInc;
int CurrentAngle,AngleInc;
};
#endif

View File

@ -1,6 +1,6 @@
/*************/
/*** Laser ***/
/*************/
/******************/
/*** TV Explode ***/
/******************/
#include "system\global.h"
#include <DStructs.h>
@ -12,197 +12,57 @@
#include "game\game.h"
#include "gfx\otpos.h"
#include "FX\FXLaser.h"
#ifndef __PLAYER_PLAYER_H__
#include "player\player.h"
#endif
int LaserWidth=1;
#include "FX\FXTVExplode.h"
#include "FX\FXBaseAnim.h"
/*****************************************************************************/
void CFXLaser::init(DVECTOR const &_Pos)
CFXBaseAnim::sFXBaseData FXCogBaseData=
{
CFX::init(_Pos);
Life=-1;
R=G=B=255;
Offset.vx=Offset.vy=0;
}
FRM__COG01,FRM__COG01,3,
FX_FLAG_LOOP | FX_FLAG_COLLIDE_BOUNCE | FX_FLAG_HAS_GRAVITY | FX_FLAG_NO_THINK_KILL,
};
/*****************************************************************************/
void CFXLaser::setOffset(DVECTOR &Pos)
CFXBaseAnim::sFXBaseData FXValveBaseData=
{
Offset=Pos;
}
FRM__ELECVALVE,FRM__ELECVALVE,1,
FX_FLAG_LOOP | FX_FLAG_COLLIDE_BOUNCE | FX_FLAG_HAS_GRAVITY | FX_FLAG_NO_THINK_KILL,
};
/*****************************************************************************/
void CFXLaser::setTarget(DVECTOR &Pos)
int TVExplodeVel=8;
int TVExplodeCogs=8;
int TVExplodeValves=8;
void CFXTVExplode::init(DVECTOR const &Pos)
{
Target=Pos;
}
CFX *NewFX;
/*****************************************************************************/
/*** Think *******************************************************************/
/*****************************************************************************/
void CFXLaser::think(int _frames)
{
CThing *Parent=getParent();
ASSERT(Parent);
int VelX,VelY;
Pos=Parent->getPos();
}
// NewFX=CFX::Create(CFX::FX_TYPE_SMOKE,Pos);
NewFX=CFX::Create(CFX::FX_TYPE_SMOKE_PUFF,Pos);
/*****************************************************************************/
/*** Render ******************************************************************/
/*****************************************************************************/
void CFXLaser::render()
{
DVECTOR renderPos0,renderPos1;
sOT *ThisOT=OtPtr+OtPos;
NewFX=CFX::Create(CFX::FX_TYPE_EXPLODE,Pos);
((CFXBaseAnim*)NewFX)->SetScale(ONE*2);
getFXRenderPos(renderPos0);
if (!canRender() || Flags & FX_FLAG_HIDDEN) return;
calcRenderPos(Target,renderPos1);
renderPos0.vx+=Offset.vx;
renderPos0.vy+=Offset.vy;
// Main Beam
LINE_F2 *L=GetPrimLF2();
L->x0=renderPos0.vx; L->y0=renderPos0.vy;
L->x1=renderPos1.vx; L->y1=renderPos1.vy;
setRGB0(L,R,G,B); addPrim(ThisOT,L);
// Surround
POLY_F4 *P=GetPrimF4();
P->x0=renderPos0.vx-LaserWidth; P->y0=renderPos0.vy-LaserWidth;
P->x1=renderPos0.vx+LaserWidth; P->y1=renderPos0.vy+LaserWidth;
P->x2=renderPos1.vx-LaserWidth; P->y2=renderPos1.vy-LaserWidth;
P->x3=renderPos1.vx+LaserWidth; P->y3=renderPos1.vy+LaserWidth;
setRGB0(P,R>>1,G>>1,B>>1); addPrim(ThisOT,P);
//
int W=renderPos1.vx-renderPos0.vx;
int H=renderPos1.vy-renderPos0.vy;
setCollisionCentreOffset( (W>>1) + Offset.vx, (H>>1) + Offset.vy );
if (W<0) W=-W;
if (H<0) H=-H;
setCollisionSize(W,H);
}
/*****************************************************************************/
/*** checkCollisionAgainst ***************************************************/
/*****************************************************************************/
int CFXLaser::checkCollisionAgainst(CThing *_thisThing, int _frames)
{
DVECTOR pos,thisThingPos;
int radius;
int collided;
pos=getCollisionCentre();
thisThingPos=_thisThing->getCollisionCentre();
radius=getCollisionRadius()+_thisThing->getCollisionRadius();
collided=false;
if(abs(pos.vx-thisThingPos.vx)<radius&&
abs(pos.vy-thisThingPos.vy)<radius)
{
CRECT thisRect,thatRect;
thisRect=getCollisionArea();
thatRect=_thisThing->getCollisionArea();
if(((thisRect.x1>=thatRect.x1&&thisRect.x1<=thatRect.x2)||(thisRect.x2>=thatRect.x1&&thisRect.x2<=thatRect.x2)||(thisRect.x1<=thatRect.x1&&thisRect.x2>=thatRect.x2))&&
((thisRect.y1>=thatRect.y1&&thisRect.y1<=thatRect.y2)||(thisRect.y2>=thatRect.y1&&thisRect.y2<=thatRect.y2)||(thisRect.y1<=thatRect.y1&&thisRect.y2>=thatRect.y2)))
{
// bounding boxes touch, now check for line vs box collision
s32 w = thatRect.x2 - thatRect.x1;
s32 h = thatRect.y2 - thatRect.y1;
s32 a = ( thatRect.x1 + thatRect.x2 ) >> 1;
s32 b = ( thatRect.y1 + thatRect.y2 ) >> 1;
s32 x1 = Pos.vx + Offset.vx;
s32 y1 = Pos.vy + Offset.vy;
s32 x2 = Target.vx;
s32 y2 = Target.vy;
s32 t1, t2, t3, t4;
if ( x1 == x2 )
for (int i=0;i<TVExplodeCogs; i++)
{
// vertical line
// bounding boxes already colliding
collided = true;
}
else if ( y1 == y2 )
{
// horizontal line
// bounding boxes already colliding
collided = true;
}
else
{
// see http://www.flipcode.com/tpractice/issue01.shtml
t1 = ( ( ( w >> 1 ) - x1 + a ) << 8 ) / ( x2 - x1 );
t2 = ( ( -( ( w >> 1 ) + x1 - a ) ) << 8 ) / ( x2 - x1 );
t3 = ( ( ( h >> 1 ) - y1 + b ) << 8 ) / ( y2 - y1 );
t4 = ( ( -( ( h >> 1 ) + y1 - b ) ) << 8 ) / ( y2 - y1 );
if ( t1 > t2 )
{
s32 temp = t2;
t2 = t1;
t1 = temp;
}
if ( t3 > t4 )
{
s32 temp = t4;
t4 = t3;
t3 = temp;
}
if ( t1 < t4 && t3 < t2 )
{
collided = true;
}
}
}
}
return collided;
}
/*****************************************************************************/
/*** CollidedWith ************************************************************/
/*****************************************************************************/
void CFXLaser::collidedWith(CThing *_thisThing)
{
switch(_thisThing->getThingType())
{
case TYPE_PLAYER:
{
CPlayer *player = (CPlayer *) _thisThing;
if ( !player->isRecoveringFromHit() )
{
player->takeDamage( DAMAGE__HIT_ENEMY );
NewFX=CFX::Create(CFX::FX_TYPE_BASE_ANIM,Pos);
NewFX->setBaseData(&FXCogBaseData);
VelX=getRndRange(TVExplodeVel*2)-TVExplodeVel;
VelY=-getRndRange(TVExplodeVel);
NewFX->setVelocity(VelX,VelY);
}
break;
}
default:
break;
}
for (int i=0;i<TVExplodeValves; i++)
{
NewFX=CFX::Create(CFX::FX_TYPE_BASE_ANIM,Pos);
NewFX->setBaseData(&FXValveBaseData);
VelX=getRndRange(TVExplodeVel*2)-TVExplodeVel;
VelY=-getRndRange(TVExplodeVel);
NewFX->setVelocity(VelX,VelY);
}
killFX();
}

View File

@ -2,30 +2,16 @@
/*** Laser ***/
/*************/
#ifndef __FX_FX_LASER_HEADER__
#define __FX_FX_LASER_HEADER__
#ifndef __FX_FX_TV_EXPLODE_HEADER__
#define __FX_FX_TV_EXPLODE_HEADER__
#include "fx/fx.h"
/*****************************************************************************/
class CFXLaser : public CFX
class CFXTVExplode : public CFX
{
public:
void init(DVECTOR const &Pos);
void think(int _frames);
void render();
virtual int canCollide() {return true;}
virtual int checkCollisionAgainst(CThing *_thisThing, int _frames);
void setOffset(DVECTOR &Pos);
void setTarget(DVECTOR &Pos);
void setRGB(u8 r,u8 g,u8 b) {R=r; G=g; B=g;}
protected:
virtual void collidedWith(CThing *_thisThing);
DVECTOR Offset,Target;
u8 R,G,B;
};
#endif