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>
|
2001-01-15 16:22:33 +01:00
|
|
|
#include "game\game.h"
|
2000-12-06 23:52:00 +01:00
|
|
|
|
|
|
|
#include "level\level.h"
|
2000-12-07 16:56:20 +01:00
|
|
|
#include "level\layertile.h"
|
2001-01-15 16:22:33 +01:00
|
|
|
#include "level\layerback.h"
|
2000-12-14 17:38:34 +01:00
|
|
|
#include "level\layertilesolid.h"
|
|
|
|
#include "level\layertile3d.h"
|
2001-02-02 20:16:49 +01:00
|
|
|
#include "level\layercollision.h"
|
2000-12-07 16:56:20 +01:00
|
|
|
|
2000-12-08 15:48:50 +01:00
|
|
|
#include "pad\pads.h"
|
|
|
|
|
2001-01-16 17:20:45 +01:00
|
|
|
DVECTOR CLevel::MapPos;
|
|
|
|
|
2001-02-12 20:40:01 +01:00
|
|
|
struct sLvlTab
|
|
|
|
{
|
|
|
|
FileEquate TileBank,Level,Tex;
|
|
|
|
};
|
|
|
|
|
|
|
|
sLvlTab LvlTable[]=
|
|
|
|
{
|
|
|
|
// C3 L3 - 6 parts
|
|
|
|
{LEVELS_CHAPTER03_LEVEL03_TBK,LEVELS_CHAPTER03_LEVEL0301_LVL,LEVELS_CHAPTER03_LEVEL03_TEX}, // 0
|
|
|
|
{LEVELS_CHAPTER03_LEVEL03_TBK,LEVELS_CHAPTER03_LEVEL0302_LVL,LEVELS_CHAPTER03_LEVEL03_TEX}, // 1
|
|
|
|
{LEVELS_CHAPTER03_LEVEL03_TBK,LEVELS_CHAPTER03_LEVEL0303_LVL,LEVELS_CHAPTER03_LEVEL03_TEX}, // 2
|
|
|
|
{LEVELS_CHAPTER03_LEVEL03_TBK,LEVELS_CHAPTER03_LEVEL0304_LVL,LEVELS_CHAPTER03_LEVEL03_TEX}, // 3
|
|
|
|
{LEVELS_CHAPTER03_LEVEL03_TBK,LEVELS_CHAPTER03_LEVEL0305_LVL,LEVELS_CHAPTER03_LEVEL03_TEX}, // 4
|
|
|
|
{LEVELS_CHAPTER03_LEVEL03_TBK,LEVELS_CHAPTER03_LEVEL0306_LVL,LEVELS_CHAPTER03_LEVEL03_TEX}, // 5
|
|
|
|
// C3 L4
|
2001-02-20 16:56:16 +01:00
|
|
|
{LEVELS_CHAPTER03_LEVEL04_TBK,LEVELS_CHAPTER03_LEVEL0401_LVL,LEVELS_CHAPTER03_LEVEL04_TEX}, // 6
|
|
|
|
{LEVELS_CHAPTER03_LEVEL04_TBK,LEVELS_CHAPTER03_LEVEL0402_LVL,LEVELS_CHAPTER03_LEVEL04_TEX}, // 7
|
|
|
|
{LEVELS_CHAPTER03_LEVEL04_TBK,LEVELS_CHAPTER03_LEVEL0403_LVL,LEVELS_CHAPTER03_LEVEL04_TEX}, // 8
|
|
|
|
{LEVELS_CHAPTER03_LEVEL04_TBK,LEVELS_CHAPTER03_LEVEL0404_LVL,LEVELS_CHAPTER03_LEVEL04_TEX}, // 9
|
|
|
|
{LEVELS_CHAPTER03_LEVEL04_TBK,LEVELS_CHAPTER03_LEVEL0404X_LVL,LEVELS_CHAPTER03_LEVEL04_TEX}, // 10
|
|
|
|
{LEVELS_CHAPTER03_LEVEL04_TBK,LEVELS_CHAPTER03_LEVEL0405_LVL,LEVELS_CHAPTER03_LEVEL04_TEX}, // 11
|
|
|
|
{LEVELS_CHAPTER03_LEVEL04_TBK,LEVELS_CHAPTER03_LEVEL0406_LVL,LEVELS_CHAPTER03_LEVEL04_TEX}, // 12
|
2001-02-12 20:40:01 +01:00
|
|
|
// C4 L1
|
2001-02-20 16:56:16 +01:00
|
|
|
{LEVELS_CHAPTER04_LEVEL01_TBK,LEVELS_CHAPTER04_LEVEL0101_LVL,LEVELS_CHAPTER04_LEVEL01_TEX}, // 13
|
|
|
|
{LEVELS_CHAPTER04_LEVEL01_TBK,LEVELS_CHAPTER04_LEVEL0102_LVL,LEVELS_CHAPTER04_LEVEL01_TEX}, // 14
|
|
|
|
{LEVELS_CHAPTER04_LEVEL01_TBK,LEVELS_CHAPTER04_LEVEL0103_LVL,LEVELS_CHAPTER04_LEVEL01_TEX}, // 15
|
|
|
|
{LEVELS_CHAPTER04_LEVEL01_TBK,LEVELS_CHAPTER04_LEVEL0104_LVL,LEVELS_CHAPTER04_LEVEL01_TEX}, // 16
|
2001-02-12 20:40:01 +01:00
|
|
|
// C4 L2
|
2001-02-20 16:56:16 +01:00
|
|
|
{LEVELS_CHAPTER04_LEVEL02_TBK,LEVELS_CHAPTER04_LEVEL0201_LVL,LEVELS_CHAPTER04_LEVEL02_TEX}, //
|
|
|
|
{LEVELS_CHAPTER04_LEVEL02_TBK,LEVELS_CHAPTER04_LEVEL0202_LVL,LEVELS_CHAPTER04_LEVEL02_TEX}, //
|
|
|
|
{LEVELS_CHAPTER04_LEVEL02_TBK,LEVELS_CHAPTER04_LEVEL0203_LVL,LEVELS_CHAPTER04_LEVEL02_TEX}, //
|
|
|
|
{LEVELS_CHAPTER04_LEVEL02_TBK,LEVELS_CHAPTER04_LEVEL0204_LVL,LEVELS_CHAPTER04_LEVEL02_TEX}, //
|
2001-02-12 20:40:01 +01:00
|
|
|
// C4 L3 - 6 parts
|
2001-02-13 21:52:06 +01:00
|
|
|
{LEVELS_CHAPTER04_LEVEL03_TBK,LEVELS_CHAPTER04_LEVEL0301_LVL,LEVELS_CHAPTER04_LEVEL03_TEX}, // 10
|
|
|
|
{LEVELS_CHAPTER04_LEVEL03_TBK,LEVELS_CHAPTER04_LEVEL0302_LVL,LEVELS_CHAPTER04_LEVEL03_TEX}, // 11
|
|
|
|
{LEVELS_CHAPTER04_LEVEL03_TBK,LEVELS_CHAPTER04_LEVEL0303_LVL,LEVELS_CHAPTER04_LEVEL03_TEX}, // 12
|
|
|
|
{LEVELS_CHAPTER04_LEVEL03_TBK,LEVELS_CHAPTER04_LEVEL0304_LVL,LEVELS_CHAPTER04_LEVEL03_TEX}, // 13
|
|
|
|
{LEVELS_CHAPTER04_LEVEL03_TBK,LEVELS_CHAPTER04_LEVEL0305_LVL,LEVELS_CHAPTER04_LEVEL03_TEX}, // 14
|
|
|
|
{LEVELS_CHAPTER04_LEVEL03_TBK,LEVELS_CHAPTER04_LEVEL0306_LVL,LEVELS_CHAPTER04_LEVEL03_TEX}, // 15
|
2001-02-12 20:40:01 +01:00
|
|
|
// C3 L4 - 7 parts
|
2001-02-13 21:52:06 +01:00
|
|
|
{LEVELS_CHAPTER04_LEVEL04_TBK,LEVELS_CHAPTER04_LEVEL0401_LVL,LEVELS_CHAPTER04_LEVEL04_TEX}, // 16
|
|
|
|
{LEVELS_CHAPTER04_LEVEL04_TBK,LEVELS_CHAPTER04_LEVEL0402_LVL,LEVELS_CHAPTER04_LEVEL04_TEX}, // 17
|
|
|
|
{LEVELS_CHAPTER04_LEVEL04_TBK,LEVELS_CHAPTER04_LEVEL0403_LVL,LEVELS_CHAPTER04_LEVEL04_TEX}, // 18
|
|
|
|
{LEVELS_CHAPTER04_LEVEL04_TBK,LEVELS_CHAPTER04_LEVEL0404_LVL,LEVELS_CHAPTER04_LEVEL04_TEX}, // 19
|
|
|
|
{LEVELS_CHAPTER04_LEVEL04_TBK,LEVELS_CHAPTER04_LEVEL0405_LVL,LEVELS_CHAPTER04_LEVEL04_TEX}, // 20
|
|
|
|
{LEVELS_CHAPTER04_LEVEL04_TBK,LEVELS_CHAPTER04_LEVEL0406_LVL,LEVELS_CHAPTER04_LEVEL04_TEX}, // 21
|
|
|
|
{LEVELS_CHAPTER04_LEVEL04_TBK,LEVELS_CHAPTER04_LEVEL0407_LVL,LEVELS_CHAPTER04_LEVEL04_TEX}, // 22
|
2001-02-12 20:40:01 +01:00
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
extern int s_globalLevelSelectThing;
|
2001-02-20 16:57:03 +01:00
|
|
|
//int Lvl=13;
|
2000-12-07 16:56:20 +01:00
|
|
|
/*****************************************************************************/
|
2001-02-12 18:18:17 +01:00
|
|
|
void CLevel::init()
|
2000-12-07 16:56:20 +01:00
|
|
|
{
|
2001-02-20 16:57:03 +01:00
|
|
|
// s_globalLevelSelectThing=Lvl;
|
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-12 21:56:51 +01:00
|
|
|
MapPos.vx=0;
|
2001-01-03 23:12:25 +01:00
|
|
|
MapPos.vy=0;
|
2001-02-12 20:40:01 +01:00
|
|
|
/*
|
2001-02-06 16:50:59 +01:00
|
|
|
TileBankHdr=(sTileBankHdr *)CFileIO::loadFile(LEVELS_CHAPTER02_LEVEL04_TBK,"Tile Bank Data");
|
2001-01-19 16:47:16 +01:00
|
|
|
LevelHdr=(sLvlHdr *)CFileIO::loadFile(LEVELS_CHAPTER02_LEVEL0401_LVL,"Level Data");
|
2001-02-09 18:01:04 +01:00
|
|
|
m_levelTPage=TPLoadTex(LEVELS_CHAPTER02_LEVEL04_TEX);
|
2001-02-12 20:40:01 +01:00
|
|
|
*/
|
|
|
|
TileBankHdr=(sTileBankHdr *)CFileIO::loadFile(LvlTable[s_globalLevelSelectThing].TileBank,"Tile Bank Data");
|
|
|
|
LevelHdr=(sLvlHdr *)CFileIO::loadFile(LvlTable[s_globalLevelSelectThing ].Level,"Level Data");
|
|
|
|
m_levelTPage=TPLoadTex(LvlTable[s_globalLevelSelectThing ].Tex);
|
2000-12-07 16:56:20 +01:00
|
|
|
|
2000-12-08 15:48:50 +01:00
|
|
|
initLayers();
|
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
|
|
|
{
|
2001-02-06 16:50:59 +01:00
|
|
|
sTri *TriList=(sTri*)MakePtr(TileBankHdr,TileBankHdr->TriList);
|
|
|
|
sQuad *QuadList=(sQuad*)MakePtr(TileBankHdr,TileBankHdr->QuadList);
|
|
|
|
sVtx *VtxList=(sVtx*)MakePtr(TileBankHdr,TileBankHdr->VtxList);
|
|
|
|
sTile *TileList=(sTile*)MakePtr(TileBankHdr,TileBankHdr->TileList);
|
2000-12-07 16:56:20 +01:00
|
|
|
|
2000-12-08 15:48:50 +01:00
|
|
|
// Back
|
2001-02-20 16:56:16 +01:00
|
|
|
|
|
|
|
if (LevelHdr->BackLayer)
|
2000-12-08 15:48:50 +01:00
|
|
|
{
|
|
|
|
sLayerHdr *Layer=(sLayerHdr*)MakePtr(LevelHdr,LevelHdr->BackLayer);
|
2001-02-20 16:56:16 +01:00
|
|
|
CLayerTile *NewLayer=new ("Back Layer") CLayerBack(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
|
|
|
*/
|
2001-02-02 20:16:49 +01:00
|
|
|
// Collision
|
|
|
|
if (LevelHdr->CollisionLayer)
|
|
|
|
{
|
|
|
|
sLayerHdr *Layer=(sLayerHdr*)MakePtr(LevelHdr,LevelHdr->CollisionLayer);
|
|
|
|
CollisionLayer=new ("Collision Layer") CLayerCollision(Layer);
|
|
|
|
}
|
|
|
|
|
2000-12-06 23:52:00 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
void CLevel::shutdown()
|
|
|
|
{
|
2001-02-12 18:18:17 +01:00
|
|
|
for (int i=0; i<CLayerTile::LAYER_TILE_TYPE_MAX; i++)
|
|
|
|
{
|
|
|
|
if (TileLayers[i])
|
|
|
|
{
|
|
|
|
TileLayers[i]->shutdown();
|
|
|
|
delete TileLayers[i];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2001-02-09 18:01:04 +01:00
|
|
|
TPFree(m_levelTPage);
|
|
|
|
CollisionLayer->shutdown(); MemFree(CollisionLayer);
|
|
|
|
MemFree(TileBankHdr);
|
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()
|
|
|
|
{
|
2001-01-08 22:42:07 +01:00
|
|
|
// Setup Constant Rot Matrix
|
2001-01-15 16:22:33 +01:00
|
|
|
MATRIX *Mtx=CGameScene::GetCamMtx();
|
2001-01-08 22:42:07 +01:00
|
|
|
|
2001-01-15 16:22:33 +01:00
|
|
|
SetRotMatrix(Mtx);
|
|
|
|
SetTransMatrix(Mtx);
|
2001-01-08 22:42:07 +01:00
|
|
|
|
|
|
|
// Setup dummy prim to ensure OtPos 0 is initialised (for fast add)
|
|
|
|
TILE_16 *Prim=GetPrimTILE16();
|
2001-01-15 16:22:33 +01:00
|
|
|
sOT *ThisOT=OtPtr+LayerOT;
|
2001-01-08 22:42:07 +01:00
|
|
|
Prim->x0=1024;
|
|
|
|
Prim->y0=1024;
|
2001-01-15 16:22:33 +01:00
|
|
|
AddPrim(ThisOT,Prim);
|
|
|
|
ASSERT(ThisOT->FirstPrim);
|
2001-01-08 22:42:07 +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
|
|
|
{
|
|
|
|
if (TileLayers[i]) TileLayers[i]->render();
|
|
|
|
}
|
2001-02-13 23:36:49 +01:00
|
|
|
#ifdef __SHOW_COLLISION__
|
|
|
|
if(CollisionLayer)
|
|
|
|
{
|
|
|
|
CollisionLayer->render(MapPos);
|
|
|
|
}
|
|
|
|
#endif
|
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::think(int _frames)
|
|
|
|
{
|
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
|
|
|
}
|
|
|
|
|
|
|
|
|
2001-02-12 16:26:00 +01:00
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
/*****************************************************************************/
|
|
|
|
/*****************************************************************************/
|
|
|
|
DVECTOR CLevel::getMapSize()
|
|
|
|
{
|
|
|
|
DVECTOR size;
|
|
|
|
sLayerHdr *layer;
|
|
|
|
|
|
|
|
layer=(sLayerHdr*)MakePtr(LevelHdr,LevelHdr->ActionLayer);
|
|
|
|
size.vx=layer->Width;
|
|
|
|
size.vy=layer->Height;
|
|
|
|
|
|
|
|
return size;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2000-12-06 23:52:00 +01:00
|
|
|
/*****************************************************************************/
|