SBSPSS/source/fx/fxfallingtile.cpp

108 lines
2.9 KiB
C++
Raw Normal View History

2001-05-16 21:06:02 +02:00
/********************/
/*** Falling Tile ***/
/********************/
2001-05-16 16:53:09 +02:00
#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-06-28 23:01:28 +02:00
#include "level\layertile3d.h"
2001-07-23 23:19:15 +02:00
#include "system\vid.h"
2001-07-24 22:17:50 +02:00
#include "gfx\actor.h"
2001-05-16 16:53:09 +02:00
2001-05-16 21:06:02 +02:00
#include "FX\FXfallingTile.h"
2001-05-16 16:53:09 +02:00
2001-05-16 21:06:02 +02:00
/*****************************************************************************/
2001-05-17 21:15:45 +02:00
const int FallingTile_DefVY=-2;
2001-06-12 22:40:20 +02:00
const int FallingTile_DefLife=64;
2001-05-16 21:06:02 +02:00
2001-05-16 16:53:09 +02:00
/*****************************************************************************/
/*****************************************************************************/
/*****************************************************************************/
2001-05-16 21:06:02 +02:00
void CFXFallingTile::init(DVECTOR const &_Pos)
2001-05-16 16:53:09 +02:00
{
CFX::init();
2001-05-16 21:06:02 +02:00
sLevelHdr *LevelHdr=CLevel::getLevelHdr();
2001-06-28 19:48:30 +02:00
ElemBank3d=LevelHdr->ElemBank3d;
2001-05-16 21:06:02 +02:00
TriList=LevelHdr->TriList;
QuadList=LevelHdr->QuadList;
VtxList=LevelHdr->VtxList;
Pos=_Pos;
Velocity.vx=getRndRange(7)-4;
Velocity.vy=FallingTile_DefVY;
Life=FallingTile_DefLife;
2001-07-29 21:17:01 +02:00
CSoundMediator::playSfx(CSoundMediator::SFX_ANY_OBJECT_FALLING,false,true);
2001-07-23 23:19:15 +02:00
Flags |=FX_FLAG_NO_THINK_KILL;
2001-05-16 16:53:09 +02:00
}
/*****************************************************************************/
/*** Think *******************************************************************/
/*****************************************************************************/
2001-05-16 21:06:02 +02:00
void CFXFallingTile::think(int _frames)
2001-05-16 16:53:09 +02:00
{
CFX::think(_frames);
2001-05-16 21:06:02 +02:00
Pos.vx+=Velocity.vx;
Pos.vy+=Velocity.vy;
Velocity.vy++;
2001-05-16 16:53:09 +02:00
}
/*****************************************************************************/
/*** Render ******************************************************************/
/*****************************************************************************/
2001-05-16 21:06:02 +02:00
void CFXFallingTile::render()
2001-05-16 16:53:09 +02:00
{
2001-05-16 21:06:02 +02:00
CFX::render();
2001-05-31 22:07:48 +02:00
if (!canRender()) return;
2001-05-16 21:06:02 +02:00
DVECTOR &RenderPos=getRenderPos();
2001-06-28 23:01:28 +02:00
u16 TileIdx=Tile>>2;
2001-07-24 22:17:50 +02:00
CModelGfx::RenderTile(RenderPos,TileIdx);
/* u16 Flip=Tile&3;
2001-06-28 23:01:28 +02:00
sFlipTable *FTab=&FlipTable[Flip];
sElem3d *Elem=&ElemBank3d[TileIdx];
int TriCount=Elem->TriCount;
sTri *TList=&TriList[Elem->TriStart];
2001-05-16 21:06:02 +02:00
2001-06-28 23:01:28 +02:00
CMX_SetTransMtxXY(&ThisRenderPos);
CMX_SetRotMatrixXY(&FTab->Mtx);
2001-05-16 21:06:02 +02:00
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;
gte_rtpt_b();
2001-06-28 23:01:28 +02:00
setShadeTex(TPrimPtr,1);
2001-05-16 21:06:02 +02:00
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
2001-06-28 23:01:28 +02:00
ThisOT=OtPtr+TList->OTOfs;
2001-05-16 21:06:02 +02:00
TList++;
gte_nclip_b();
gte_stsxy3_ft3(TPrimPtr);
gte_stopz(&ClipZ);
2001-06-28 23:01:28 +02:00
ClipZ^=FTab->ClipCode;
if (ClipZ<0)
2001-05-16 21:06:02 +02:00
{
addPrim(ThisOT,TPrimPtr);
TPrimPtr++;
}
}
SetPrimPtr((u8*)TPrimPtr);
2001-07-24 22:17:50 +02:00
*/
2001-05-16 16:53:09 +02:00
}