SBSPSS/source/fx/fxjfish.cpp

167 lines
4.0 KiB
C++
Raw Normal View History

2001-05-05 20:12:30 +02:00
/**********************/
/*** 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()
{
2001-05-05 21:42:49 +02:00
for (int L=0; L<Width; L++)
{
MemFree(FXList[L]);
}
2001-05-05 20:12:30 +02:00
MemFree(FXList);
MemFree(WidthTable);
MemFree(HeightTable);
CFX::shutdown();
}
/*****************************************************************************/
/*****************************************************************************/
void CFXJellyFishLegs::SetUp(int _Width,int _Gap,int _Length,int _Count)
{
2001-05-21 16:52:09 +02:00
/*
2001-05-05 20:12:30 +02:00
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;
2001-05-06 00:20:09 +02:00
if (dH<2) dH=2;
2001-05-05 20:12:30 +02:00
HeightTable[H]=(s16)dH;
2001-05-05 21:42:49 +02:00
// printf("%i %i =%i\n",H,Ofs,HeightTable[H]);
2001-05-05 20:12:30 +02:00
}
2001-05-21 16:52:09 +02:00
*/
2001-05-05 20:12:30 +02:00
}
/*****************************************************************************/
/*** 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)
{
2001-05-21 16:52:09 +02:00
/* ASSERT(FXList);
2001-05-05 20:12:30 +02:00
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];
}
2001-05-21 16:52:09 +02:00
*/
2001-05-05 20:12:30 +02:00
}
/*****************************************************************************/
/*** Render ******************************************************************/
/*****************************************************************************/
2001-05-05 21:42:49 +02:00
const int Trans=3;
int LX=8;
int LY=32;
2001-05-05 20:12:30 +02:00
void CFXJellyFishLegs::render()
{
2001-05-21 16:52:09 +02:00
/*
2001-05-05 20:12:30 +02:00
DVECTOR _MapOfs=CLevel::getCameraPos();
DVECTOR MapOfs;
int dRGB=256/Count;
s16 *dH=HeightTable;
2001-05-05 21:42:49 +02:00
_MapOfs.vx+=LX;
_MapOfs.vy+=LY;
2001-05-10 18:16:57 +02:00
if (!Parent->canRender()) return;
2001-05-05 20:12:30 +02:00
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;
2001-05-09 21:57:57 +02:00
POLY_FT4 *Ft4=m_spriteBank->printFT4(FRM__TENTACLE,LastPos.vx,LastPos.vy,0,0,OtPos);
2001-05-05 20:12:30 +02:00
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;
}
2001-05-21 16:52:09 +02:00
*/
2001-05-05 20:12:30 +02:00
}