This commit is contained in:
Daveo 2001-05-05 18:12:30 +00:00
parent deb21add92
commit 6ee022b872
4 changed files with 427 additions and 0 deletions

153
source/fx/fx.cpp Normal file
View File

@ -0,0 +1,153 @@
/*********************/
/*** 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"
#include "FX\FX.h"
#include "FX\FXjfish.h"
/* FX
Jellyfish legs
Bubbles (inc acid)
Electricity lightning bolt
Electricity sheet lightning
Electricity Blast
Electricity Radial?
Electricity projectile
Shockwave - From falling items
Daze stars
water/acid/lava/oil
drip
splashes
water/acid/lava.oil
drops
waterfall
waterfall end (splash)
fireballs
steam
smoke
flames
marsh gas
explosions (implode!!)
Coral debris
***************************
Level Effect Emitters
Bubble
Acid drip
Acid Flow
steam
smoke
fireballs
flames
gas
*/
/*****************************************************************************/
CFX *CFX::Create(const FX_TYPE Type,CThing *Parent)
{
CFX *NewFX;
switch(Type)
{
case FX_TYPE_JELLYFISH_LEGS:
NewFX=new ("JellyFish Legs") CFXJellyFishLegs();
break;
case FX_TYPE_BUBBLE:
case FX_TYPE_BUBBLE_WATER:
case FX_TYPE_BUBBLE_ACID:
case FX_TYPE_BUBBLE_LAVA:
case FX_TYPE_BUBBLE_OIL:
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:
case FX_TYPE_DROP:
case FX_TYPE_DROP_WATER:
case FX_TYPE_DROP_ACID:
case FX_TYPE_DROP_LAVA:
case FX_TYPE_DROP_OIL:
case FX_TYPE_SPLASH:
case FX_TYPE_SPLASH_WATER:
case FX_TYPE_SPLASH_ACID:
case FX_TYPE_SPLASH_LAVA:
case FX_TYPE_SPLASH_OIL:
case FX_TYPE_CASCADE:
case FX_TYPE_CASCADE_SPLASH:
case FX_TYPE_FIREBALL:
case FX_TYPE_CLOUD:
case FX_TYPE_CLOUD_STEAN:
case FX_TYPE_CLOUD_SMOKE:
case FX_TYPE_CLOUD_GAS:
case FX_TYPE_FLAMES:
case FX_TYPE_EXPLODE:
case FX_TYPE_DEBRIS:
default:
ASSERT(!"UNKNOWN FX TYPE");
return NULL;
}
NewFX->init();
// Pos=NewFX->getSizeForPlacement();
// Pos.vx=_pos->vx+(NewFXPos.vx/2);
// Pos.vy=_pos->vy+(NewFXPos.vy/2)-16;
// NewFX->setPos(&NewFXPos);
if (Parent)
{
Parent->addChild(NewFX);
}
return NewFX;
}
/*****************************************************************************/
/*****************************************************************************/
/*****************************************************************************/
void CFX::init()
{
CFXThing::init();
m_spriteBank=new ("FX Sprite") SpriteBank();
m_spriteBank->load(SPRITES_SPRITES_SPR);
}
/*****************************************************************************/
void CFX::shutdown()
{
m_spriteBank->dump(); delete m_spriteBank;
CFXThing::shutdown();
}
/*****************************************************************************/
void CFX::think(int _frames)
{
CFXThing::think(_frames);
}
/*****************************************************************************/
void CFX::render()
{
}

66
source/fx/fx.h Normal file
View File

@ -0,0 +1,66 @@
/*********************/
/*** FX Base Class ***/
/*********************/
#ifndef __FX_FX_HEADER__
#define __FX_FX_HEADER__
#include "thing/thing.h"
/*****************************************************************************/
class SpriteBank;
class CFX : public CFXThing
{
public:
enum FX_TYPE
{
FX_TYPE_JELLYFISH_LEGS,
FX_TYPE_BUBBLE,
FX_TYPE_BUBBLE_WATER,
FX_TYPE_BUBBLE_ACID,
FX_TYPE_BUBBLE_LAVA,
FX_TYPE_BUBBLE_OIL,
FX_TYPE_LIGHTNING_BOLT,
FX_TYPE_LIGHTNING_SHEET,
FX_TYPE_LIGHTNING_BLAST,
FX_TYPE_LIGHTNING_RADIAL,
FX_TYPE_LIGHTNING_PROJECTILE,
FX_TYPE_SHOCKWAVE,
FX_TYPE_DAZE,
FX_TYPE_DROP,
FX_TYPE_DROP_WATER,
FX_TYPE_DROP_ACID,
FX_TYPE_DROP_LAVA,
FX_TYPE_DROP_OIL,
FX_TYPE_SPLASH,
FX_TYPE_SPLASH_WATER,
FX_TYPE_SPLASH_ACID,
FX_TYPE_SPLASH_LAVA,
FX_TYPE_SPLASH_OIL,
FX_TYPE_CASCADE,
FX_TYPE_CASCADE_SPLASH,
FX_TYPE_FIREBALL,
FX_TYPE_CLOUD,
FX_TYPE_CLOUD_STEAN,
FX_TYPE_CLOUD_SMOKE,
FX_TYPE_CLOUD_GAS,
FX_TYPE_FLAMES,
FX_TYPE_EXPLODE,
FX_TYPE_DEBRIS,
};
static CFX *Create(const FX_TYPE Type,CThing *Parent);
virtual void init();
virtual void shutdown();
virtual void think(int _frames);
virtual void render();
virtual int canCollide() {return false;}
protected:
SpriteBank *m_spriteBank;
};
#endif

171
source/fx/fxjfish.cpp Normal file
View File

@ -0,0 +1,171 @@
/**********************/
/*** JellyFish Legs ***/
/**********************/
#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"
#include "FX\FXjfish.h"
/*****************************************************************************/
/*****************************************************************************/
/*****************************************************************************/
void CFXJellyFishLegs::init()
{
CFX::init();
FXList=0;
}
/*****************************************************************************/
void CFXJellyFishLegs::shutdown()
{
MemFree(FXList);
MemFree(WidthTable);
MemFree(HeightTable);
CFX::shutdown();
}
/*****************************************************************************/
/*****************************************************************************/
void CFXJellyFishLegs::SetUp(int _Width,int _Gap,int _Length,int _Count)
{
XOfs=-(_Width/2);
Width=_Width/_Gap;
Gap=_Gap;
Length=_Length;
Count=_Count;
FXList=(sList**)MemAlloc(Width*sizeof(sList*),"FishLegTable");
for (int L=0; L<Width; L++)
{
sList *ThisList=(sList*)MemAlloc(Count*sizeof(sList),"FishLeg");
FXList[L]=ThisList;
}
ListIdx=0;
WidthTable=(s16*)MemAlloc(Count*sizeof(s16),"FishLegWTable");
for (int W=0; W<Count; W++)
{
int dW=((8<<12)/Count)/2;
WidthTable[W]=(dW*W)>>12;
}
HeightTable=(s16*)MemAlloc(Width*sizeof(s16),"FishLegHTable");
int AInc=1024/Width;
for (int H=0; H<Width; H++)
{
int Ofs=abs(H-(Width/2));
int dH=8-Ofs;
dH*=2;
if (dH>8) dH=8;
HeightTable[H]=(s16)dH;
printf("%i %i =%i\n",H,Ofs,HeightTable[H]);
}
}
/*****************************************************************************/
/*** Think *******************************************************************/
/*****************************************************************************/
//int XT[]={-3,-3,-3,-2,-2,-2,-1,-1, +1,+1,+2,+2,+2,+3,+3,+3};
int XT[]={-3,-2,-2,-2,-2,-1,-1,-1, +1,+1,+1,+2,+2,+2,+2,+3};
void CFXJellyFishLegs::think(int _frames)
{
ASSERT(FXList);
CFX::think(_frames);
ListIdx--;
if (ListIdx<0) ListIdx+=Count;
for (int i=0; i<Width; i++)
{
sList *ThisList=FXList[i];
ThisList[ListIdx].Ofs=Parent->getPos();
// ThisList[ListIdx].Ofs.vx/=16;
// ThisList[ListIdx].Ofs.vy/=16;
int XO=getRnd();
XO&=15;
ThisList[ListIdx].Ofs.vx+=XT[XO];
}
}
/*****************************************************************************/
/*** Render ******************************************************************/
/*****************************************************************************/
int Trans=0;
void CFXJellyFishLegs::render()
{
DVECTOR _MapOfs=CLevel::getCameraPos();
DVECTOR MapOfs;
int dRGB=256/Count;
s16 *dH=HeightTable;
MapOfs.vx=_MapOfs.vx+XOfs;
for (int L=0; L<Width; L++)
{
u8 C=255;
s16 *dW=WidthTable;
int Idx=ListIdx;
sList *List=FXList[L];
DVECTOR LastPos;
int LastdW;
int Height=*dH++;
MapOfs.vy=_MapOfs.vy;
LastPos.vx=List[Idx].Ofs.vx-MapOfs.vx;
LastPos.vy=List[Idx].Ofs.vy-MapOfs.vy;
LastdW=*dW++;
MapOfs.vy-=Length;
Idx++;
for (int i=0; i<Count-1; i++)
{
if (Idx>=Count) Idx=0;
POLY_FT4 *Ft4=m_spriteBank->printFT4(FRM__TENTACLE,LastPos.vx,LastPos.vy,0,0,0);
Ft4->x0=LastPos.vx+0+LastdW; Ft4->y0=LastPos.vy;
Ft4->x1=LastPos.vx+8-LastdW; Ft4->y1=LastPos.vy;
setSemiTrans(Ft4,1);
Ft4->tpage|=Trans<<5;
LastPos.vx=List[Idx].Ofs.vx-MapOfs.vx;
LastPos.vy=List[Idx].Ofs.vy-MapOfs.vy;
LastdW=*dW++;
Ft4->x2=LastPos.vx+0+LastdW; Ft4->y2=LastPos.vy;
Ft4->x3=LastPos.vx+8-LastdW; Ft4->y3=LastPos.vy;
setRGB0(Ft4,C,C,C);
C-=dRGB;
MapOfs.vy-=Height;
Idx++;
}
MapOfs.vx+=Gap;
}
}
/*
for (int i=0; i<Count-1; i++)
{
if (Idx>=Count) Idx=0;
POLY *Ft4=m_spriteBank->printFT4(LastPos.vx,LastPos.vy);
LINE_F2 *P=GetPrimLF2();
P->x0=LastPos.vx;
P->y0=LastPos.vy;
LastPos.vx=List[Idx].Ofs.vx-MapOfs.vx;
LastPos.vy=List[Idx].Ofs.vy-MapOfs.vy;
P->x1=LastPos.vx;
P->y1=LastPos.vy;
setRGB0(P,C,C,C);
C-=dRGB;
if (!i) setRGB0(P,255,0,0);
AddPrim(OtPtr,P);
MapOfs.vy-=Length;
Idx++;
}
*/

37
source/fx/fxjfish.h Normal file
View File

@ -0,0 +1,37 @@
/**********************/
/*** JellyFish Legs ***/
/**********************/
#ifndef __FX_FX_JELLYFISH_LEGS_HEADER__
#define __FX_FX_JELLYFISH_LEGS_HEADER__
#include "fx/fx.h"
/*****************************************************************************/
class CFXJellyFishLegs : public CFX
{
public:
struct sList
{
DVECTOR Ofs;
};
virtual void init();
virtual void shutdown();
virtual void think(int _frames);
virtual void render();
void SetUp(int _Width,int _Gap,int _Length,int _Count);
protected:
int XOfs;
int Width,Gap;
int Length,Count;
sList **FXList;
int ListIdx;
s16 *WidthTable;
s16 *HeightTable;
};
#endif