2000-12-06 23:52:00 +01:00
|
|
|
/*************/
|
|
|
|
/*** Level ***/
|
|
|
|
/*************/
|
|
|
|
|
|
|
|
#include "system\global.h"
|
|
|
|
#include "fileio\fileio.h"
|
2000-12-07 16:56:20 +01:00
|
|
|
#include "utils\utils.h"
|
|
|
|
#include "gfx\tpage.h"
|
2000-12-08 15:48:50 +01:00
|
|
|
#include "gfx\prim.h"
|
2000-12-06 23:52:00 +01:00
|
|
|
#include <DStructs.h>
|
|
|
|
|
|
|
|
#include "level\level.h"
|
2000-12-07 16:56:20 +01:00
|
|
|
#include "level\layertile.h"
|
2000-12-14 17:38:34 +01:00
|
|
|
#include "level\layertilesolid.h"
|
|
|
|
#include "level\layertile3d.h"
|
2000-12-07 16:56:20 +01:00
|
|
|
|
2000-12-08 15:48:50 +01:00
|
|
|
#include "pad\pads.h"
|
|
|
|
|
2000-12-07 16:56:20 +01:00
|
|
|
/*****************************************************************************/
|
|
|
|
CLevel::CLevel()
|
|
|
|
{
|
2000-12-09 18:22:06 +01:00
|
|
|
for (int i=0; i<CLayerTile::LAYER_TILE_TYPE_MAX; i++)
|
2000-12-08 15:48:50 +01:00
|
|
|
{
|
|
|
|
TileLayers[i]=0;
|
|
|
|
}
|
2000-12-14 17:38:34 +01:00
|
|
|
|
2000-12-12 21:56:51 +01:00
|
|
|
MapPos.vx=0;
|
2001-01-03 23:12:25 +01:00
|
|
|
MapPos.vy=0;
|
2000-12-07 16:56:20 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
CLevel::~CLevel()
|
|
|
|
{
|
2000-12-09 18:22:06 +01:00
|
|
|
for (int i=0; i<CLayerTile::LAYER_TILE_TYPE_MAX; i++)
|
2000-12-08 15:48:50 +01:00
|
|
|
{
|
|
|
|
if (TileLayers[i]) delete TileLayers[i];
|
|
|
|
}
|
2000-12-07 16:56:20 +01:00
|
|
|
}
|
2000-12-06 23:52:00 +01:00
|
|
|
|
|
|
|
/*****************************************************************************/
|
2001-01-03 23:12:25 +01:00
|
|
|
int ZPos=6500;
|
|
|
|
|
2000-12-06 23:52:00 +01:00
|
|
|
void CLevel::init()
|
|
|
|
{
|
2000-12-12 21:56:51 +01:00
|
|
|
LevelHdr=(sLvlHdr *)CFileIO::loadFile(LEVEL04_LEVEL04_LVL,"Level Data");
|
|
|
|
TPLoadTex(LEVEL04_LEVEL04_TEX);
|
2000-12-07 16:56:20 +01:00
|
|
|
|
2000-12-08 15:48:50 +01:00
|
|
|
initLayers();
|
2001-01-03 23:12:25 +01:00
|
|
|
|
|
|
|
// Setup Constand Rot Matrix
|
|
|
|
MATRIX Mtx;
|
|
|
|
|
|
|
|
SetIdent(&Mtx);
|
|
|
|
Mtx.t[2]=ZPos;
|
|
|
|
SetRotMatrix(&Mtx);
|
|
|
|
SetTransMatrix(&Mtx);
|
2000-12-07 16:56:20 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
2000-12-08 15:48:50 +01:00
|
|
|
void CLevel::initLayers()
|
2000-12-07 16:56:20 +01:00
|
|
|
{
|
2000-12-08 15:48:50 +01:00
|
|
|
sTri *TriList=(sTri*)MakePtr(LevelHdr,LevelHdr->TriList);
|
|
|
|
sQuad *QuadList=(sQuad*)MakePtr(LevelHdr,LevelHdr->QuadList);
|
|
|
|
sVtx *VtxList=(sVtx*)MakePtr(LevelHdr,LevelHdr->VtxList);
|
|
|
|
sTile *TileList=(sTile*)MakePtr(LevelHdr,LevelHdr->TileList);
|
2000-12-07 16:56:20 +01:00
|
|
|
|
2000-12-08 15:48:50 +01:00
|
|
|
// Back
|
|
|
|
if (LevelHdr->BackLayer)
|
|
|
|
{
|
|
|
|
sLayerHdr *Layer=(sLayerHdr*)MakePtr(LevelHdr,LevelHdr->BackLayer);
|
2000-12-14 17:38:34 +01:00
|
|
|
CLayerTile *NewLayer=new ("Back Layer") CLayerTileSolid(Layer, TileList, TriList, QuadList, VtxList);
|
2000-12-12 21:56:51 +01:00
|
|
|
NewLayer->init(MapPos,3);
|
2000-12-09 18:22:06 +01:00
|
|
|
TileLayers[CLayerTile::LAYER_TILE_TYPE_BACK]=NewLayer;
|
2000-12-08 15:48:50 +01:00
|
|
|
}
|
2000-12-12 21:56:51 +01:00
|
|
|
|
2000-12-08 15:48:50 +01:00
|
|
|
// Mid
|
|
|
|
if (LevelHdr->MidLayer)
|
|
|
|
{
|
|
|
|
sLayerHdr *Layer=(sLayerHdr*)MakePtr(LevelHdr,LevelHdr->MidLayer);
|
2000-12-09 18:22:06 +01:00
|
|
|
CLayerTile *NewLayer=new ("Mid Layer") CLayerTile(Layer, TileList, TriList, QuadList, VtxList);
|
2000-12-12 21:56:51 +01:00
|
|
|
NewLayer->init(MapPos,2);
|
2000-12-09 18:22:06 +01:00
|
|
|
TileLayers[CLayerTile::LAYER_TILE_TYPE_MID]=NewLayer;
|
2000-12-08 15:48:50 +01:00
|
|
|
}
|
2000-12-14 17:38:34 +01:00
|
|
|
|
2000-12-08 15:48:50 +01:00
|
|
|
// Action
|
|
|
|
if (LevelHdr->ActionLayer)
|
2000-12-07 16:56:20 +01:00
|
|
|
{
|
2000-12-08 15:48:50 +01:00
|
|
|
sLayerHdr *Layer=(sLayerHdr*)MakePtr(LevelHdr,LevelHdr->ActionLayer);
|
2000-12-14 17:38:34 +01:00
|
|
|
CLayerTile *NewLayer=new ("Action Layer") CLayerTile3d(Layer, TileList, TriList, QuadList, VtxList);
|
|
|
|
NewLayer->init(MapPos,0);
|
2000-12-09 18:22:06 +01:00
|
|
|
TileLayers[CLayerTile::LAYER_TILE_TYPE_ACTION]=NewLayer;
|
2000-12-08 15:48:50 +01:00
|
|
|
}
|
2000-12-14 17:38:34 +01:00
|
|
|
|
|
|
|
/*
|
2000-12-08 15:48:50 +01:00
|
|
|
// Fore
|
|
|
|
if (LevelHdr->ForeLayer)
|
|
|
|
{
|
|
|
|
sLayerHdr *Layer=(sLayerHdr*)MakePtr(LevelHdr,LevelHdr->ForeLayer);
|
2000-12-09 18:22:06 +01:00
|
|
|
CLayerTile *NewLayer=new ("Fore Layer") CLayerTile(Layer, TileList, TriList, QuadList, VtxList);
|
2000-12-08 15:48:50 +01:00
|
|
|
NewLayer->init();
|
2000-12-09 18:22:06 +01:00
|
|
|
TileLayers[CLayerTile::LAYER_TILE_TYPE_FORE]=NewLayer;
|
2000-12-07 16:56:20 +01:00
|
|
|
}
|
2000-12-09 18:22:06 +01:00
|
|
|
*/
|
2000-12-06 23:52:00 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
void CLevel::shutdown()
|
|
|
|
{
|
2000-12-07 16:56:20 +01:00
|
|
|
MemFree(LevelHdr);
|
2000-12-06 23:52:00 +01:00
|
|
|
}
|
|
|
|
|
2000-12-08 15:48:50 +01:00
|
|
|
/*****************************************************************************/
|
|
|
|
/*****************************************************************************/
|
2000-12-06 23:52:00 +01:00
|
|
|
/*****************************************************************************/
|
|
|
|
void CLevel::render()
|
|
|
|
{
|
2000-12-09 18:22:06 +01:00
|
|
|
for (int i=0; i<CLayerTile::LAYER_TILE_TYPE_MAX; i++)
|
2000-12-08 15:48:50 +01:00
|
|
|
{
|
|
|
|
if (TileLayers[i]) TileLayers[i]->render();
|
|
|
|
}
|
2000-12-06 23:52:00 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
2000-12-08 15:48:50 +01:00
|
|
|
/*****************************************************************************/
|
|
|
|
/*****************************************************************************/
|
2000-12-09 18:22:06 +01:00
|
|
|
int MapSpd=8;
|
2000-12-06 23:52:00 +01:00
|
|
|
void CLevel::think(int _frames)
|
|
|
|
{
|
2000-12-08 15:48:50 +01:00
|
|
|
int padh = PadGetHeld( 0 );
|
|
|
|
|
2000-12-12 21:56:51 +01:00
|
|
|
if (padh & PAD_LEFT) MapPos.vx-=MapSpd;
|
|
|
|
if (padh & PAD_RIGHT) MapPos.vx+=MapSpd;
|
|
|
|
if (padh & PAD_UP) MapPos.vy-=MapSpd;
|
|
|
|
if (padh & PAD_DOWN) MapPos.vy+=MapSpd;
|
2000-12-09 18:22:06 +01:00
|
|
|
|
2000-12-12 21:56:51 +01:00
|
|
|
if (MapPos.vx<0) MapPos.vx=0;
|
|
|
|
if (MapPos.vy<0) MapPos.vy=0;
|
2000-12-08 15:48:50 +01:00
|
|
|
|
2000-12-09 18:22:06 +01:00
|
|
|
for (int i=0; i<CLayerTile::LAYER_TILE_TYPE_MAX; i++)
|
2000-12-08 15:48:50 +01:00
|
|
|
{
|
2000-12-12 21:56:51 +01:00
|
|
|
if (TileLayers[i]) TileLayers[i]->think(MapPos);
|
2000-12-08 15:48:50 +01:00
|
|
|
}
|
2000-12-06 23:52:00 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|