From e24c93004dba94f29fec3bb6ebe784c2bac3347a Mon Sep 17 00:00:00 2001 From: Daveo Date: Wed, 16 May 2001 19:06:02 +0000 Subject: [PATCH] --- source/fx/fx.cpp | 39 +++++++++++--- source/fx/fx.h | 10 ++-- source/fx/fxfallingtile.cpp | 102 +++++++++++++++++++++++++++++++----- source/fx/fxfallingtile.h | 38 +++++++------- source/game/game.h | 2 +- 5 files changed, 146 insertions(+), 45 deletions(-) diff --git a/source/fx/fx.cpp b/source/fx/fx.cpp index 57a0dc31b..0f9b22a98 100644 --- a/source/fx/fx.cpp +++ b/source/fx/fx.cpp @@ -13,6 +13,7 @@ #include "FX\FX.h" #include "FX\FXjfish.h" +#include "FX\FXfallingTile.h" /* FX Jellyfish legs @@ -62,7 +63,7 @@ Level Effect Emitters */ /*****************************************************************************/ -CFX *CFX::Create(const FX_TYPE Type,CThing *Parent) +CFX *CFX::Create(const FX_TYPE Type) { CFX *NewFX; @@ -71,6 +72,9 @@ CFX *NewFX; case FX_TYPE_JELLYFISH_LEGS: NewFX=new ("JellyFish Legs") CFXJellyFishLegs(); break; + case FX_TYPE_FALLINGTILE: + NewFX=new ("Falling Tile") CFXFallingTile(); + break; case FX_TYPE_BUBBLE: case FX_TYPE_BUBBLE_WATER: case FX_TYPE_BUBBLE_ACID: @@ -109,16 +113,34 @@ CFX *NewFX; return NULL; } - if (Parent) - { - Parent->addChild(NewFX); - } - - NewFX->init(); - return NewFX; } +/*****************************************************************************/ +CFX *CFX::Create(const FX_TYPE Type,CThing *Parent) +{ +CFX *NewFX=CFX::Create(Type); + + if (Parent) + { + Parent->addChild(NewFX); + } + + NewFX->init(); + + return NewFX; +} + +/*****************************************************************************/ +CFX *CFX::Create(const FX_TYPE Type,DVECTOR const &Pos) +{ +CFX *NewFX=CFX::Create(Type); + + NewFX->init(Pos); + + return NewFX; +} + /*****************************************************************************/ /*****************************************************************************/ /*****************************************************************************/ @@ -147,5 +169,6 @@ void CFX::think(int _frames) /*****************************************************************************/ void CFX::render() { + CFXThing::render(); } diff --git a/source/fx/fx.h b/source/fx/fx.h index 0f4d4eb5f..96bff2e71 100644 --- a/source/fx/fx.h +++ b/source/fx/fx.h @@ -15,6 +15,7 @@ public: enum FX_TYPE { FX_TYPE_JELLYFISH_LEGS, + FX_TYPE_FALLINGTILE, FX_TYPE_BUBBLE, FX_TYPE_BUBBLE_WATER, FX_TYPE_BUBBLE_ACID, @@ -49,21 +50,24 @@ public: FX_TYPE_DEBRIS, }; +static CFX *Create(const FX_TYPE Type); static CFX *Create(const FX_TYPE Type,CThing *Parent); +static CFX *Create(const FX_TYPE Type,DVECTOR const &Pos); virtual void init(); +virtual void init(DVECTOR const &Pos){}; virtual void shutdown(); virtual void think(int _frames); virtual void render(); virtual int canCollide() {return false;} +virtual u8 isSetToShutdown() {return( false );} virtual void SetOtPos(int Ot) {OtPos=Ot;} protected: - - SpriteBank *m_spriteBank; - s32 OtPos; + SpriteBank *m_spriteBank; + s32 OtPos; }; #endif diff --git a/source/fx/fxfallingtile.cpp b/source/fx/fxfallingtile.cpp index cf530a6ae..178f7236c 100644 --- a/source/fx/fxfallingtile.cpp +++ b/source/fx/fxfallingtile.cpp @@ -1,6 +1,6 @@ -/**************************/ -/*** Emitter Base Class ***/ -/**************************/ +/********************/ +/*** Falling Tile ***/ +/********************/ #include "system\global.h" #include @@ -10,39 +10,115 @@ #include #include "level\level.h" -#include "FX\FXemit.h" +#include "FX\FXfallingTile.h" +/*****************************************************************************/ +int TT=1; +int FallingTile_DefVY=-2; +int FallingTile_DefLife=32; + /*****************************************************************************/ /*****************************************************************************/ /*****************************************************************************/ -void CFXEmitter::init() +void CFXFallingTile::init(DVECTOR const &_Pos) { CFX::init(); -// ParticleList=MemAlloc(Count); +sLevelHdr *LevelHdr=CLevel::getLevelHdr(); + + TileBank3d=LevelHdr->TileBank3d; + TriList=LevelHdr->TriList; + QuadList=LevelHdr->QuadList; + VtxList=LevelHdr->VtxList; + Pos=_Pos; + + Velocity.vx=getRndRange(7)-4; + Velocity.vy=FallingTile_DefVY; + Life=FallingTile_DefLife; + Tile=TT++; + } /*****************************************************************************/ -void CFXEmitter::shutdown() +void CFXFallingTile::shutdown() { - MemFree(ParticleList); CFX::shutdown(); } -/*****************************************************************************/ - /*****************************************************************************/ /*** Think *******************************************************************/ /*****************************************************************************/ -void CFXEmitter::think(int _frames) +void CFXFallingTile::think(int _frames) { -// ASSERT(FXList); CFX::think(_frames); + Pos.vx+=Velocity.vx; + Pos.vy+=Velocity.vy; + Velocity.vy++; + if (Life) Life--; } /*****************************************************************************/ /*** Render ******************************************************************/ /*****************************************************************************/ -void CFXEmitter::render() +const int PXOfs=-16*16; // Must sort these out to be single global! +const int PYOfs=-8*16; + +void CFXFallingTile::render() { + CFX::render(); + + if (!canRender() && Life) return; + +u8 *PrimPtr=GetPrimPtr(); +POLY_FT3 *TPrimPtr=(POLY_FT3*)PrimPtr; +sVtx *P0,*P1,*P2; +u32 T0,T1,T2; +s32 ClipZ; +sOT *ThisOT; +MATRIX Mtx; +DVECTOR &RenderPos=getRenderPos(); +VECTOR ThisRenderPos; + + SetIdentNoTrans(&Mtx); + + ThisRenderPos.vx=PXOfs+RenderPos.vx; + ThisRenderPos.vy=PYOfs+RenderPos.vy; + + gte_SetRotMatrix(&Mtx); + CMX_SetTransMtxXY(&ThisRenderPos); + + sTile3d *ThisTile=&TileBank3d[Tile]; + int TriCount=ThisTile->TriCount; + sTri *TList=&TriList[ThisTile->TriStart]; + + while (TriCount--) + { + P0=&VtxList[TList->P0]; P1=&VtxList[TList->P1]; P2=&VtxList[TList->P2]; + gte_ldv3(P0,P1,P2); + setlen(TPrimPtr, GPU_PolyFT3Tag); + TPrimPtr->code=TList->PolyCode; + setRGB0(TPrimPtr,128,128,128); + gte_rtpt_b(); + + T0=*(u32*)&TList->uv0; // Get UV0 & TPage + T1=*(u32*)&TList->uv1; // Get UV1 & Clut + T2=*(u16*)&TList->uv2; // Get UV2 + *(u32*)&TPrimPtr->u0=T0; // Set UV0 + *(u32*)&TPrimPtr->u1=T1; // Set UV1 + *(u16*)&TPrimPtr->u2=T2; // Set UV2 + + ThisOT=OtPtr; + TList++; + gte_nclip_b(); + gte_stsxy3_ft3(TPrimPtr); + gte_stopz(&ClipZ); + if (ClipZ<=0) + { + addPrim(ThisOT,TPrimPtr); + TPrimPtr++; + } + } + + SetPrimPtr((u8*)TPrimPtr); + } diff --git a/source/fx/fxfallingtile.h b/source/fx/fxfallingtile.h index 6fb8cbf27..9353ba43d 100644 --- a/source/fx/fxfallingtile.h +++ b/source/fx/fxfallingtile.h @@ -1,37 +1,35 @@ -/**************************/ -/*** Emitter Base Class ***/ -/**************************/ +/********************/ +/*** Falling Tile ***/ +/********************/ -#ifndef __FX_FX_EMITTER_HEADER__ -#define __FX_FX_EMITTER_HEADER__ +#ifndef __FX_FX_FALLING_TILE_HEADER__ +#define __FX_FX_FALLING_TILE_HEADER__ #include "fx/fx.h" /*****************************************************************************/ -class CFXParticle; -class CFXEmitter : public CFX +class CFXFallingTile : public CFX { public: -virtual void init(); +virtual void init(DVECTOR const &Pos); virtual void shutdown(); virtual void think(int _frames); virtual void render(); +virtual u8 isSetToShutdown() {return(Life<=0);} + void SetTile(int T) {Tile=T;} protected: - CFXParticle *ParticleList; + u16 Tile; + u16 Life; + DVECTOR Velocity; + + sTile3d *TileBank3d; + sTri *TriList; + sQuad *QuadList; + sVtx *VtxList; + }; -/*****************************************************************************/ -class CFXParticle : public CFX -{ -public: -virtual void init(); -virtual void shutdown(); -virtual void think(int _frames); -virtual void render(); - -protected: -}; #endif diff --git a/source/game/game.h b/source/game/game.h index f1d28975a..ed7ab01e5 100644 --- a/source/game/game.h +++ b/source/game/game.h @@ -50,7 +50,7 @@ virtual int canPause(); static void setReadyToExit() {s_readyToExit=true;} static void levelFinished() {s_levelFinished=true;} static void restartlevel() {s_restartLevel=true;} - + CLevel &GetLevel() {return(Level);} // static MATRIX &GetCamMtx() {return(CamMtx);} static ACTOR_TYPE getActorType( int actorNum ) {return actorType[actorNum];}