diff --git a/source/fx/fxsteam.cpp b/source/fx/fxsteam.cpp new file mode 100644 index 000000000..4c37e4b16 --- /dev/null +++ b/source/fx/fxsteam.cpp @@ -0,0 +1,142 @@ +/************************/ +/*** Cloud Base Class ***/ +/************************/ + +#include "system\global.h" +#include +#include "utils\utils.h" +#include "gfx\prim.h" +#include "gfx\sprbank.h" +#include +#include "level\level.h" + +#include "FX\FXcloud.h" + + +DVECTOR SmokeVel; +u16 AngleInc=16; + +u8 StartR=255; +u8 StartG=255; +u8 StartB=255; +s8 RInc=-8; +s8 BInc=-8; +s8 GInc=-8; +s16 StartScaleX=256; +s16 ScaleXInc=256; +s16 StartScaleY=256; +s16 ScaleYInc=256; + +/*****************************************************************************/ +/*****************************************************************************/ +/*****************************************************************************/ +void CFXCloud::init(DVECTOR const &_Pos) +{ + CFX::init(); + Pos=_Pos; + HeadIdx=0; + ListCount=1; + Angle=0; +} + +/*****************************************************************************/ +void CFXCloud::shutdown() +{ + CFX::shutdown(); +} + +/*****************************************************************************/ +/*** Think *******************************************************************/ +/*****************************************************************************/ +int SS=4; +void CFXCloud::think(int _frames) +{ +int ThisIdx=HeadIdx; +DVECTOR Vel=SmokeVel; + if (Parent) + { + this->setPos(Parent->getPos()); + } + + CFX::think(_frames); + + HeadIdx--; + if (HeadIdx<0) HeadIdx+=ListCount; + + if (Parent) + { + setPos(Parent->getPos()); + } + List[HeadIdx].Ofs=getPos(); + + + for (int i=0; i>SS; + ThisElem.Ofs.vy+=Vel.vy>>SS; + Vel.vx+=SmokeVel.vx; + Vel.vy+=SmokeVel.vy; + } + ListCount++; + if (ListCount>MAX_TRAIL) + { + ListCount=MAX_TRAIL; + } + +} + +/*****************************************************************************/ +/*** Render ******************************************************************/ +/*****************************************************************************/ +int ST=3; + +void CFXCloud::render() +{ + CFX::render(); + + if (canRender()) + { + DVECTOR const &MapOfs=CLevel::getCameraPos(); + DVECTOR RenderPos; + int ThisIdx=HeadIdx; + + int ThisAngle=Angle; + int ThisScaleX=StartScaleX; + int ThisScaleY=StartScaleY; + u8 ThisR=StartR; + u8 ThisG=StartG; + u8 ThisB=StartB; + + for (int i=0; iprintRotatedScaledSprite(FRM__SMOKE,RenderPos.vx,RenderPos.vy,ThisScaleX,ThisScaleY,ThisAngle,OtPos*0); + setShadeTex(Ft4,0); + setSemiTrans(Ft4,1); + setRGB0(Ft4,ThisR,ThisB,ThisB); + Ft4->tpage|=ST<<5; + + ThisR+=RInc; + ThisG+=GInc; + ThisB+=BInc; + + ThisAngle+=AngleInc; + ThisAngle&=4095; + ThisScaleX+=ScaleXInc; + ThisScaleY+=ScaleYInc; + + ThisIdx++; + ThisIdx&=MAX_TRAIL-1; + } + Angle+=AngleInc/2; + Angle&=4095; + + } +} diff --git a/source/fx/fxsteam.h b/source/fx/fxsteam.h new file mode 100644 index 000000000..a6f961cc1 --- /dev/null +++ b/source/fx/fxsteam.h @@ -0,0 +1,35 @@ +/**********************/ +/*** JellyFish Legs ***/ +/**********************/ + +#ifndef __FX_FX_CLOUD_HEADER__ +#define __FX_FX_CLOUD_HEADER__ + +#include "fx/fx.h" + +/*****************************************************************************/ +class CFXCloud : public CFX +{ +public: + struct sList + { + DVECTOR Ofs; + }; + enum + { + MAX_TRAIL = 16 + }; + +virtual void init(DVECTOR const &Pos); +virtual void shutdown(); +virtual void think(int _frames); +virtual void render(); + +protected: + sList List[MAX_TRAIL]; + int ListCount; + int HeadIdx; + int Angle; +}; + +#endif