SBSPSS/source/fx/fxjfish.cpp

175 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"
2001-05-30 22:36:44 +02:00
#include "game\game.h"
2001-05-05 20:12:30 +02:00
#include "FX\FXjfish.h"
2001-05-31 00:05:41 +02:00
static const int LegCount=3;
static const int LegWInc=32/LegCount;
static const int LegHInc=-4;
static const int LegAngleInc=7;
2001-05-05 20:12:30 +02:00
/*****************************************************************************/
/*****************************************************************************/
/*****************************************************************************/
2001-05-30 22:36:44 +02:00
void CFXJellyFishLegs::init(DVECTOR const &_Pos)
2001-05-05 20:12:30 +02:00
{
CFX::init();
2001-05-30 22:36:44 +02:00
Pos=_Pos;
Ofs.vx=0; Ofs.vy=0;
Angle=getRnd();
AngleInc=LegAngleInc+getRndRange(3);
2001-06-11 21:32:41 +02:00
Scale = ONE;
2001-05-05 20:12:30 +02:00
}
/*****************************************************************************/
2001-08-03 21:10:05 +02:00
void CFXJellyFishLegs::Setup(int XOfs,int YOfs,bool _XFlip)
2001-05-05 20:12:30 +02:00
{
2001-05-30 22:36:44 +02:00
Ofs.vx=XOfs;
Ofs.vy=YOfs;
2001-08-03 21:10:05 +02:00
XFlip=_XFlip;
2001-05-05 20:12:30 +02:00
}
/*****************************************************************************/
/*** Think *******************************************************************/
/*****************************************************************************/
2001-05-30 22:36:44 +02:00
2001-05-05 20:12:30 +02:00
void CFXJellyFishLegs::think(int _frames)
{
2001-05-30 22:36:44 +02:00
CFX::think(_frames);
Angle++; Angle&=CIRCLE_TAB_MASK;
AngleInc=LegAngleInc;
2001-05-05 20:12:30 +02:00
}
/*****************************************************************************/
/*** Render ******************************************************************/
/*****************************************************************************/
2001-08-02 18:35:39 +02:00
const int LegXInc=4;
2001-08-04 19:16:11 +02:00
2001-05-05 20:12:30 +02:00
void CFXJellyFishLegs::render()
{
2001-08-02 20:45:20 +02:00
CThing *Parent=getParent();
2001-05-30 22:36:44 +02:00
CFX::render();
2001-08-02 20:45:20 +02:00
// if (!canRender()) return;
if (!Parent->canRender()) return;
2001-08-04 19:16:11 +02:00
2001-05-30 22:36:44 +02:00
SpriteBank *SprBank=CGameScene::getSpriteBank();;
DVECTOR RenderPos=getRenderPos();
int WOfs=0;
int H;
int ThisAngle=Angle;
int LegHeight=SprBank->getFrameHeight(FRM__LEG)-4;
2001-06-11 21:32:41 +02:00
int ScaleWInc=(Scale*LegWInc)>>12;
int ScaleHInc=(Scale*LegHInc)>>12;
2001-08-02 18:35:39 +02:00
int XInc=LegXInc;
2001-05-30 22:36:44 +02:00
RenderPos.vx+=Ofs.vx;
RenderPos.vy+=Ofs.vy;
2001-08-04 19:16:11 +02:00
if (!XFlip)
{
XInc=-XInc-1;
}
2001-05-30 22:36:44 +02:00
for (int i=0; i<LegCount; i++)
2001-05-05 20:12:30 +02:00
{
2001-05-30 22:36:44 +02:00
ThisAngle+=AngleInc;
ThisAngle&=CIRCLE_TAB_MASK;
H=LegHeight+(CircleTable[ThisAngle]>>5);
2001-06-11 21:32:41 +02:00
POLY_FT4 *Ft4;
2001-08-04 19:16:11 +02:00
2001-08-02 18:35:39 +02:00
Ft4=SprBank->printFT4Scaled(FRM__LEG,RenderPos.vx+(i*XInc),RenderPos.vy,XFlip,0,OtPos,Scale>>4);
2001-05-30 22:36:44 +02:00
if (!XFlip)
{
2001-06-26 16:21:22 +02:00
Ft4->x0+=WOfs/2;
Ft4->x2+=WOfs/2;
Ft4->x1-=WOfs/2;
Ft4->x3-=WOfs/2;
2001-05-30 22:36:44 +02:00
}
else
{
2001-06-26 16:21:22 +02:00
Ft4->x0+=WOfs/2;
Ft4->x2+=WOfs/2;
Ft4->x1-=WOfs/2;
Ft4->x3-=WOfs/2;
2001-05-30 22:36:44 +02:00
}
2001-08-03 21:10:05 +02:00
Ft4->y2=Ft4->y0+H;
Ft4->y3=Ft4->y1+H;
RenderPos.vy+=H+ScaleHInc;
WOfs+=ScaleWInc;
}
}
/*****************************************************************************/
/*** Render on map ***********************************************************/
/*****************************************************************************/
2001-08-09 16:23:58 +02:00
void CFXJellyFishLegs::renderOnMapScreen( DVECTOR drawPos, int XOfs, int YOfs )
2001-08-03 21:10:05 +02:00
{
SpriteBank *SprBank=CGameScene::getSpriteBank();;
DVECTOR RenderPos=drawPos;
int WOfs=0;
int H;
int ThisAngle=0;
int LegHeight=SprBank->getFrameHeight(FRM__LEG)-4;
int ScaleWInc=(ONE*LegWInc)>>12;
int ScaleHInc=(ONE*LegHInc)>>12;
int XInc=LegXInc;
2001-08-09 16:23:58 +02:00
RenderPos.vx+=XOfs;
RenderPos.vy+=YOfs;
2001-08-03 21:10:05 +02:00
if (!XFlip) XInc=-XInc;
for (int i=0; i<LegCount; i++)
{
ThisAngle+=AngleInc;
ThisAngle&=CIRCLE_TAB_MASK;
H=LegHeight+(CircleTable[ThisAngle]>>5);
POLY_FT4 *Ft4;
Ft4=SprBank->printFT4Scaled(FRM__LEG,RenderPos.vx+(i*XInc),RenderPos.vy,XFlip,0,OtPos,ONE>>4);
if (!XFlip)
{
Ft4->x0+=WOfs/2;
Ft4->x2+=WOfs/2;
Ft4->x1-=WOfs/2;
Ft4->x3-=WOfs/2;
}
else
{
Ft4->x0+=WOfs/2;
Ft4->x2+=WOfs/2;
Ft4->x1-=WOfs/2;
Ft4->x3-=WOfs/2;
}
2001-05-30 22:36:44 +02:00
Ft4->y2=Ft4->y0+H;
Ft4->y3=Ft4->y1+H;
2001-06-11 21:32:41 +02:00
RenderPos.vy+=H+ScaleHInc;
WOfs+=ScaleWInc;
2001-05-05 20:12:30 +02:00
}
}