SBSPSS/source/level/level.cpp

922 lines
28 KiB
C++
Raw Normal View History

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"
2001-04-03 23:28:56 +02:00
#include "utils\pak.h"
2000-12-07 16:56:20 +01:00
#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\layertile3d.h"
2001-02-02 20:16:49 +01:00
#include "level\layercollision.h"
2000-12-07 16:56:20 +01:00
2001-04-02 17:48:02 +02:00
#include "gfx\font.h"
2001-05-29 22:31:02 +02:00
#include "triggers\trigger.h"
/*
2001-03-06 17:59:04 +01:00
#ifndef __TRIGGERS_TLEVEXIT_H__
#include "triggers\tlevexit.h"
#endif
2001-04-23 23:11:15 +02:00
#ifndef __TRIGGERS_TRESTART_H__
#include "triggers\trestart.h"
2001-04-17 22:09:33 +02:00
#endif
2001-05-01 23:34:41 +02:00
#ifndef __TRIGGERS_TTELEPRT_H__
#include "triggers\tteleprt.h"
#endif
2001-05-04 03:35:52 +02:00
#ifndef __TRIGGERS_TCAMLOCK_H__
#include "triggers\tcamlock.h"
#endif
2001-05-08 18:58:07 +02:00
#ifndef __TRIGGERS_TWATER_H__
#include "triggers\twater.h"
#endif
2001-05-29 22:31:02 +02:00
*/
2001-05-08 18:58:07 +02:00
2001-04-02 19:02:29 +02:00
#ifndef __PICKUPS_PICKUP_H__
#include "pickups\pickup.h"
#endif
2001-05-09 22:15:01 +02:00
#ifndef __PICKUPS_PSPATULA_H__
#include "pickups\pspatula.h"
#endif
2001-06-01 20:59:33 +02:00
#ifndef __PICKUPS_PKELP_H__
#include "pickups\pkelp.h"
#endif
2001-03-29 18:12:32 +02:00
#ifndef __SOUND_SOUND_H__
#include "sound\sound.h"
#endif
2001-04-02 17:48:02 +02:00
#ifndef __VID_HEADER_
#include "system\vid.h"
#endif
2001-04-03 23:28:56 +02:00
#include "gfx\actor.h"
2000-12-08 15:48:50 +01:00
2001-05-04 21:34:09 +02:00
#ifndef __ENEMY_NPC_H__
#include "enemy\npc.h"
#endif
#ifndef __FRIEND_FRIEND_H__
#include "friend\friend.h"
#endif
#ifndef __PLATFORM_PLATFORM_H__
#include "platform\platform.h"
#endif
#ifndef __HAZARD_HAZARD_H__
#include "hazard\hazard.h"
#endif
#ifndef __PROJECTL_PROJECTL_H__
#include "projectl\projectl.h"
#endif
2001-05-10 16:09:06 +02:00
#ifndef __JELLFISH_JELLFISH_H__
#include "jellfish\jellfish.h"
#endif
2001-05-09 22:15:01 +02:00
#ifndef __GAME_GAMESLOT_H__
#include "game\gameslot.h"
#endif
2001-05-31 23:17:33 +02:00
#ifndef __LOCALE_TEXTDBASE_H__
#include "locale\textdbase.h"
#endif
2001-07-20 23:20:46 +02:00
#ifndef _ANIMTEX_HEADER_
#include "gfx\animtex.h"
#endif
2001-05-16 21:06:47 +02:00
#include "fx\fx.h"
#include "fx\fxfallingtile.h"
2001-05-04 21:34:09 +02:00
2001-05-03 00:49:59 +02:00
2001-05-30 16:58:29 +02:00
// Level data include files:
#include <CHAPTER01_LEVEL01_INF.h>
#include <CHAPTER01_LEVEL02_INF.h>
#include <CHAPTER01_LEVEL03_INF.h>
#include <CHAPTER01_LEVEL04_INF.h>
#include <CHAPTER02_LEVEL01_INF.h>
#include <CHAPTER02_LEVEL02_INF.h>
#include <CHAPTER02_LEVEL03_INF.h>
#include <CHAPTER02_LEVEL04_INF.h>
#include <CHAPTER03_LEVEL01_INF.h>
#include <CHAPTER03_LEVEL02_INF.h>
#include <CHAPTER03_LEVEL03_INF.h>
#include <CHAPTER03_LEVEL04_INF.h>
#include <CHAPTER04_LEVEL01_INF.h>
#include <CHAPTER04_LEVEL02_INF.h>
#include <CHAPTER04_LEVEL03_INF.h>
#include <CHAPTER04_LEVEL04_INF.h>
#include <CHAPTER05_LEVEL01_INF.h>
#include <CHAPTER05_LEVEL02_INF.h>
#include <CHAPTER05_LEVEL03_INF.h>
#include <CHAPTER05_LEVEL04_INF.h>
#include <CHAPTER06_LEVEL01_INF.h>
#include <CHAPTER06_LEVEL02_INF.h>
#include <CHAPTER06_LEVEL03_INF.h>
#include <CHAPTER06_LEVEL04_INF.h>
#include <CHAPTER06_LEVEL05_INF.h>
2001-07-31 18:49:59 +02:00
#ifdef __VERSION_DEBUG__
int PretendToBeAPS2=false;
#endif
2001-05-30 16:58:29 +02:00
2001-04-19 01:04:03 +02:00
/*****************************************************************************/
2001-05-16 21:06:47 +02:00
sLvlTab LvlTable[]=
2001-02-12 20:40:01 +01:00
{
2001-03-05 18:04:28 +01:00
// C1
2001-08-08 20:46:51 +02:00
{1,1, -1, CHAPTER01_LEVEL01_INF_TOTAL_ITEM_GOLDEN_SPATULA, LEVELS_CHAPTER01_LEVEL01_LVL,LEVELS_CHAPTER01_LEVEL01_TEX, CSoundMediator::SONG_CHAPTER1_LEVEL1, STR__CHAPTER_1,STR__CHAPTER_1_LEVEL_1, CFmaScene::FMA_SCRIPT__NONE },
{1,2, -1, CHAPTER01_LEVEL02_INF_TOTAL_ITEM_GOLDEN_SPATULA, LEVELS_CHAPTER01_LEVEL02_LVL,LEVELS_CHAPTER01_LEVEL02_TEX, CSoundMediator::SONG_CHAPTER1_LEVEL2, STR__CHAPTER_1,STR__CHAPTER_1_LEVEL_2, CFmaScene::FMA_SCRIPT__NONE },
{1,3, -1, CHAPTER01_LEVEL03_INF_TOTAL_ITEM_GOLDEN_SPATULA, LEVELS_CHAPTER01_LEVEL03_LVL,LEVELS_CHAPTER01_LEVEL03_TEX, CSoundMediator::SONG_CHAPTER1_LEVEL3, STR__CHAPTER_1,STR__CHAPTER_1_LEVEL_3, CFmaScene::FMA_SCRIPT__NONE },
{1,4, -1, CHAPTER01_LEVEL04_INF_TOTAL_ITEM_GOLDEN_SPATULA, LEVELS_CHAPTER01_LEVEL04_LVL,LEVELS_CHAPTER01_LEVEL04_TEX, CSoundMediator::SONG_CHAPTER1_LEVEL4, STR__CHAPTER_1,STR__CHAPTER_1_LEVEL_4, CFmaScene::FMA_SCRIPT__CH1FINISHED },
{1,5, -1, CHAPTER06_LEVEL01_INF_TOTAL_ITEM_KELP_TOKEN, LEVELS_CHAPTER06_LEVEL01_LVL,LEVELS_CHAPTER06_LEVEL01_TEX, CSoundMediator::SONG_CHAPTER6_BIGWHEEL, STR__KELP_WORLD,STR__CHAPTER_6_LEVEL_1, CFmaScene::FMA_SCRIPT__NONE },
2001-03-05 18:04:28 +01:00
// C2
2001-08-08 20:46:51 +02:00
{2,1, +1, CHAPTER02_LEVEL01_INF_TOTAL_ITEM_GOLDEN_SPATULA, LEVELS_CHAPTER02_LEVEL01_LVL,LEVELS_CHAPTER02_LEVEL01_TEX, CSoundMediator::SONG_CHAPTER2_LEVEL1, STR__CHAPTER_2,STR__CHAPTER_2_LEVEL_1, CFmaScene::FMA_SCRIPT__NONE },
{2,2, +1, CHAPTER02_LEVEL02_INF_TOTAL_ITEM_GOLDEN_SPATULA, LEVELS_CHAPTER02_LEVEL02_LVL,LEVELS_CHAPTER02_LEVEL02_TEX, CSoundMediator::SONG_CHAPTER2_LEVEL2, STR__CHAPTER_2,STR__CHAPTER_2_LEVEL_2, CFmaScene::FMA_SCRIPT__NONE },
{2,3, -1, CHAPTER02_LEVEL03_INF_TOTAL_ITEM_GOLDEN_SPATULA, LEVELS_CHAPTER02_LEVEL03_LVL,LEVELS_CHAPTER02_LEVEL03_TEX, CSoundMediator::SONG_CHAPTER2_LEVEL3, STR__CHAPTER_2,STR__CHAPTER_2_LEVEL_3, CFmaScene::FMA_SCRIPT__NONE },
{2,4, -1, CHAPTER02_LEVEL04_INF_TOTAL_ITEM_GOLDEN_SPATULA, LEVELS_CHAPTER02_LEVEL04_LVL,LEVELS_CHAPTER02_LEVEL04_TEX, CSoundMediator::SONG_CHAPTER2_LEVEL4, STR__CHAPTER_2,STR__CHAPTER_2_LEVEL_4, CFmaScene::FMA_SCRIPT__CH2FINISHED },
{2,5, -1, CHAPTER06_LEVEL02_INF_TOTAL_ITEM_KELP_TOKEN, LEVELS_CHAPTER06_LEVEL02_LVL,LEVELS_CHAPTER06_LEVEL02_TEX, CSoundMediator::SONG_CHAPTER6_ROLLERCOASTER, STR__KELP_WORLD,STR__CHAPTER_6_LEVEL_2, CFmaScene::FMA_SCRIPT__NONE },
2001-06-22 22:06:39 +02:00
// C3
2001-08-08 20:46:51 +02:00
{3,1, +1, CHAPTER03_LEVEL01_INF_TOTAL_ITEM_GOLDEN_SPATULA, LEVELS_CHAPTER03_LEVEL01_LVL,LEVELS_CHAPTER03_LEVEL01_TEX, CSoundMediator::SONG_CHAPTER3_LEVEL1, STR__CHAPTER_3,STR__CHAPTER_3_LEVEL_1, CFmaScene::FMA_SCRIPT__NONE },
{3,2, -1, CHAPTER03_LEVEL02_INF_TOTAL_ITEM_GOLDEN_SPATULA, LEVELS_CHAPTER03_LEVEL02_LVL,LEVELS_CHAPTER03_LEVEL02_TEX, CSoundMediator::SONG_CHAPTER3_LEVEL2, STR__CHAPTER_3,STR__CHAPTER_3_LEVEL_2, CFmaScene::FMA_SCRIPT__NONE },
{3,3, -1, CHAPTER03_LEVEL03_INF_TOTAL_ITEM_GOLDEN_SPATULA, LEVELS_CHAPTER03_LEVEL03_LVL,LEVELS_CHAPTER03_LEVEL03_TEX, CSoundMediator::SONG_CHAPTER3_LEVEL3, STR__CHAPTER_3,STR__CHAPTER_3_LEVEL_3, CFmaScene::FMA_SCRIPT__NONE },
{3,4, -1, CHAPTER03_LEVEL04_INF_TOTAL_ITEM_GOLDEN_SPATULA, LEVELS_CHAPTER03_LEVEL04_LVL,LEVELS_CHAPTER03_LEVEL04_TEX, CSoundMediator::SONG_CHAPTER3_LEVEL4, STR__CHAPTER_3,STR__CHAPTER_3_LEVEL_4, CFmaScene::FMA_SCRIPT__CH3FINISHED },
{3,5, -1, CHAPTER06_LEVEL03_INF_TOTAL_ITEM_KELP_TOKEN, LEVELS_CHAPTER06_LEVEL03_LVL,LEVELS_CHAPTER06_LEVEL03_TEX, CSoundMediator::SONG_CHAPTER6_TUNNELOFLOVE, STR__KELP_WORLD,STR__CHAPTER_6_LEVEL_3, CFmaScene::FMA_SCRIPT__NONE },
2001-06-22 22:06:39 +02:00
// C4
2001-08-08 20:46:51 +02:00
{4,1, -1, CHAPTER04_LEVEL01_INF_TOTAL_ITEM_GOLDEN_SPATULA, LEVELS_CHAPTER04_LEVEL01_LVL,LEVELS_CHAPTER04_LEVEL01_TEX, CSoundMediator::SONG_CHAPTER4_LEVEL1, STR__CHAPTER_4,STR__CHAPTER_4_LEVEL_1, CFmaScene::FMA_SCRIPT__NONE },
{4,2, -1, CHAPTER04_LEVEL02_INF_TOTAL_ITEM_GOLDEN_SPATULA, LEVELS_CHAPTER04_LEVEL02_LVL,LEVELS_CHAPTER04_LEVEL02_TEX, CSoundMediator::SONG_CHAPTER4_LEVEL2, STR__CHAPTER_4,STR__CHAPTER_4_LEVEL_2, CFmaScene::FMA_SCRIPT__NONE },
{4,3, -1, CHAPTER04_LEVEL03_INF_TOTAL_ITEM_GOLDEN_SPATULA, LEVELS_CHAPTER04_LEVEL03_LVL,LEVELS_CHAPTER04_LEVEL03_TEX, CSoundMediator::SONG_CHAPTER4_LEVEL3, STR__CHAPTER_4,STR__CHAPTER_4_LEVEL_3, CFmaScene::FMA_SCRIPT__NONE },
{4,4, -1, CHAPTER04_LEVEL04_INF_TOTAL_ITEM_GOLDEN_SPATULA, LEVELS_CHAPTER04_LEVEL04_LVL,LEVELS_CHAPTER04_LEVEL04_TEX, CSoundMediator::SONG_CHAPTER4_LEVEL4, STR__CHAPTER_4,STR__CHAPTER_4_LEVEL_4, CFmaScene::FMA_SCRIPT__CH4FINISHED },
{4,5, -1, CHAPTER06_LEVEL04_INF_TOTAL_ITEM_KELP_TOKEN, LEVELS_CHAPTER06_LEVEL04_LVL,LEVELS_CHAPTER06_LEVEL04_TEX, CSoundMediator::SONG_CHAPTER6_GHOSTTRAIN, STR__KELP_WORLD,STR__CHAPTER_6_LEVEL_4, CFmaScene::FMA_SCRIPT__NONE },
2001-06-22 22:06:39 +02:00
// C5
2001-08-08 20:46:51 +02:00
{5,1, -1, CHAPTER05_LEVEL01_INF_TOTAL_ITEM_GOLDEN_SPATULA, LEVELS_CHAPTER05_LEVEL01_LVL,LEVELS_CHAPTER05_LEVEL01_TEX, CSoundMediator::SONG_CHAPTER5_LEVEL1, STR__CHAPTER_5,STR__CHAPTER_5_LEVEL_1, CFmaScene::FMA_SCRIPT__NONE },
{5,2, -1, CHAPTER05_LEVEL02_INF_TOTAL_ITEM_GOLDEN_SPATULA, LEVELS_CHAPTER05_LEVEL02_LVL,LEVELS_CHAPTER05_LEVEL02_TEX, CSoundMediator::SONG_CHAPTER5_LEVEL2, STR__CHAPTER_5,STR__CHAPTER_5_LEVEL_2, CFmaScene::FMA_SCRIPT__NONE },
{5,3, -1, CHAPTER05_LEVEL03_INF_TOTAL_ITEM_GOLDEN_SPATULA, LEVELS_CHAPTER05_LEVEL03_LVL,LEVELS_CHAPTER05_LEVEL03_TEX, CSoundMediator::SONG_CHAPTER5_LEVEL3, STR__CHAPTER_5,STR__CHAPTER_5_LEVEL_3, CFmaScene::FMA_SCRIPT__NONE },
{5,4, -1, CHAPTER05_LEVEL04_INF_TOTAL_ITEM_GOLDEN_SPATULA, LEVELS_CHAPTER05_LEVEL04_LVL,LEVELS_CHAPTER05_LEVEL04_TEX, CSoundMediator::SONG_CHAPTER5_LEVEL4, STR__CHAPTER_5,STR__CHAPTER_5_LEVEL_4, CFmaScene::FMA_SCRIPT__CH5FINISHED },
{5,5, -1, CHAPTER06_LEVEL05_INF_TOTAL_ITEM_KELP_TOKEN, LEVELS_CHAPTER06_LEVEL05_LVL,LEVELS_CHAPTER06_LEVEL05_TEX, CSoundMediator::SONG_CHAPTER6_SNAILRACE, STR__KELP_WORLD,STR__CHAPTER_6_LEVEL_5, CFmaScene::FMA_SCRIPT__NONE },
2001-06-22 22:06:39 +02:00
// FMA
2001-08-08 20:46:51 +02:00
{6,0, -1, 0, LEVELS_FMA_SHADYSHOALS_LVL,LEVELS_FMA_SHADYSHOALS_TEX, CSoundMediator::SONG_FMA, STR__NOW_LOADING,STR__BLANK, CFmaScene::FMA_SCRIPT__NONE },
{6,0, -1, 0, LEVELS_FMA_CONTROLROOM_LVL,LEVELS_FMA_CONTROLROOM_TEX, CSoundMediator::SONG_FMA, STR__NOW_LOADING,STR__BLANK, CFmaScene::FMA_SCRIPT__NONE },
2001-04-24 22:35:31 +02:00
2001-02-12 20:40:01 +01:00
};
2001-05-16 21:06:47 +02:00
const int LvlTableSize=sizeof(LvlTable)/sizeof(sLvlTab);
2001-02-12 20:40:01 +01:00
2001-08-07 17:41:47 +02:00
const FileEquate loadingScreens[6]=
2001-04-03 23:28:56 +02:00
{
2001-06-04 18:10:06 +02:00
LOADINGSCREENS_PINEAPPLE_GFX, // Chapter 1
LOADINGSCREENS_CULTURE_GFX, // Chapter 2
LOADINGSCREENS_PICKLES_GFX, // Chapter 3
LOADINGSCREENS_MONITOR_GFX, // Chapter 4
LOADINGSCREENS_KARATE_GFX, // Chapter 5
2001-04-03 23:28:56 +02:00
};
2001-04-19 01:04:03 +02:00
/*****************************************************************************/
2001-05-16 21:06:47 +02:00
DVECTOR CLevel::MapPos;
DVECTOR CLevel::s_playerSpawnPos;
2001-08-08 20:46:51 +02:00
int CLevel::s_playerFacing;
2001-05-16 21:06:47 +02:00
sLevelHdr *CLevel::LevelHdr;
2001-04-19 01:04:03 +02:00
2001-05-04 23:58:41 +02:00
u8 CLevel::m_isBossRespawn;
s32 CLevel::m_bossHealth;
2001-08-03 23:04:12 +02:00
CNpcCheckpointHazard *CLevel::m_checkpoint;
2001-04-03 23:28:56 +02:00
/*****************************************************************************/
2001-05-16 21:06:47 +02:00
CLevel::CLevel()
2001-04-03 23:28:56 +02:00
{
}
2001-03-05 18:04:28 +01:00
2001-04-03 23:28:56 +02:00
/*****************************************************************************/
2001-04-19 01:04:03 +02:00
void CLevel::init(int LevelNo)
2001-04-03 23:28:56 +02:00
{
// Load it
2001-04-19 01:04:03 +02:00
sLvlTab *lvlTab=&LvlTable[LevelNo];
2001-04-03 23:28:56 +02:00
2001-07-28 18:45:46 +02:00
CSoundMediator::setSong((CSoundMediator::SONGID)lvlTab->songId);
2001-04-04 18:14:52 +02:00
2001-04-19 17:12:21 +02:00
LevelHdr=(sLevelHdr*)CFileIO::loadFile(lvlTab->LevelFilename,"Level");
2001-06-28 19:48:30 +02:00
LevelHdr->ElemBank2d=(sElem2d*) MakePtr(LevelHdr,(int)LevelHdr->ElemBank2d);
LevelHdr->ElemBank3d=(sElem3d*) MakePtr(LevelHdr,(int)LevelHdr->ElemBank3d);
2001-04-19 01:04:03 +02:00
LevelHdr->TriList=(sTri*) MakePtr(LevelHdr,(int)LevelHdr->TriList);
LevelHdr->QuadList=(sQuad*) MakePtr(LevelHdr,(int)LevelHdr->QuadList);
LevelHdr->VtxList=(sVtx*) MakePtr(LevelHdr,(int)LevelHdr->VtxList);
2001-07-12 22:10:15 +02:00
LevelHdr->VtxIdxList=(u16*) MakePtr(LevelHdr,(int)LevelHdr->VtxIdxList);
2001-04-27 18:59:41 +02:00
LevelHdr->ModelList=(sModel*) MakePtr(LevelHdr,(int)LevelHdr->ModelList);
2001-04-04 18:14:52 +02:00
2001-07-28 18:45:46 +02:00
// Deal with RGB Tables (and create if none)
if (LevelHdr->RGBLayer)
{
sLayerRGBHdr *RGBHdr=(sLayerRGBHdr*) MakePtr(LevelHdr,(int)LevelHdr->RGBLayer+sizeof(sLayerHdr));
m_RGBMap=(u8*) MakePtr(LevelHdr,(int)RGBHdr->RGBMap);
m_RGBTable=(u8*) MakePtr(LevelHdr,(int)RGBHdr->RGBTable);
}
else
{ // Make blank RGB data
sLayerHdr *LayerLayer=(sLayerHdr*)MakePtr(LevelHdr,LevelHdr->ActionLayer);
int LvlSize=LayerLayer->Width*LayerLayer->Height;
m_RGBMap=(u8*)MemAlloc(LvlSize,"BlankRGBMap"); ASSERT(m_RGBMap);
memset(m_RGBMap,0,LvlSize);
m_RGBTable=(u8*)MemAlloc(16*4,"BlankRGBTable"); ASSERT(m_RGBTable);
u8 RGB=127;
for (int c=0; c<16; c++)
{
m_RGBTable[(c*4)+0]=RGB;
m_RGBTable[(c*4)+1]=RGB;
m_RGBTable[(c*4)+2]=RGB;
m_RGBTable[(c*4)+3]=0;
RGB+=6;
}
}
CModelGfx::SetData(LevelHdr);
2001-04-19 01:04:03 +02:00
m_levelTPage=TPLoadTex(lvlTab->TexFilename);
2001-04-07 23:17:27 +02:00
s_playerSpawnPos.vx=LevelHdr->PlayerStartX*16;
2001-04-20 22:46:57 +02:00
s_playerSpawnPos.vy=LevelHdr->PlayerStartY*16+16;
2001-08-08 20:46:51 +02:00
s_playerFacing=lvlTab->SBFacing;
2001-04-07 23:17:27 +02:00
2001-04-03 23:28:56 +02:00
MapPos.vx=MapPos.vy=0;
initLayers();
2001-05-04 23:58:41 +02:00
m_isBossRespawn = false;
2001-08-03 23:04:12 +02:00
m_checkpoint = NULL;
2001-05-04 23:58:41 +02:00
m_bossHealth = 0;
2001-07-20 23:20:46 +02:00
int level=GameScene.getLevelNumber();
int chapter=GameScene.getChapterNumber();
2001-08-02 15:09:42 +02:00
if ( chapter == 5 && level == 5 || // snail race
2001-07-20 23:20:46 +02:00
chapter == 5 && level == 4 ) // tuna canning
{
CAnimTex::SetSpeed( -4 );
}
2001-04-03 23:28:56 +02:00
}
2001-05-16 21:06:47 +02:00
/*****************************************************************************/
bool CLevel::GetNextLevel(int &Lvl)
{
bool Finished=false;
Lvl++;
2001-05-23 22:24:33 +02:00
if (Lvl>=LvlTableSize)
2001-05-16 21:06:47 +02:00
{
Lvl=0;
Finished=true;
}
2001-05-17 15:43:43 +02:00
2001-05-16 21:06:47 +02:00
return(Finished);
}
2001-04-03 23:28:56 +02:00
/*****************************************************************************/
2001-07-28 18:45:46 +02:00
void CLevel::DisplayLoadingScreen(int LevelNo)
2001-04-03 23:28:56 +02:00
{
2001-06-28 21:14:44 +02:00
ScalableFontBank font;
char buf[256];
u8 *s_image;
int i;
2001-08-06 15:04:29 +02:00
if (LevelNo==-1)
2001-08-07 17:41:47 +02:00
{
// default loading screen
s_image=LoadPakScreen(LOADINGSCREENS_TEENAGE_GFX);
sprintf(buf,"%s",TranslationDatabase::getString(STR__NOW_LOADING));
}
else if (LevelNo==-2)
{
// fma laoding screen..
s_image=LoadPakScreen( LOADINGSCREENS_PIZZA_GFX);
sprintf(buf,"%s",TranslationDatabase::getString(STR__NOW_LOADING));
2001-08-06 15:04:29 +02:00
}
else
{
s_image=LoadPakScreen(loadingScreens[LvlTable[LevelNo].Chapter-1]);
sprintf(buf,"%s\n\n%s",TranslationDatabase::getString(LvlTable[LevelNo].ChapterLoadingText),TranslationDatabase::getString(LvlTable[LevelNo].LevelLoadingText));
}
2001-07-28 18:45:46 +02:00
2001-08-06 15:04:29 +02:00
ASSERT(s_image);
SetScreenImage(s_image);
2001-04-02 17:48:02 +02:00
font.initialise(&standardFont);
font.setJustification(FontBank::JUST_CENTRE);
2001-06-28 21:14:44 +02:00
font.setScale(370);
2001-04-02 17:48:02 +02:00
for(i=0;i<2;i++)
{
2001-08-07 17:41:47 +02:00
font.setColour(255,255,255);
font.print(256 ,90 ,buf);
font.setColour(0,0,0);
font.print(256-1,90-1,buf);
font.print(256-1,90 ,buf);
font.print(256-1,90+1,buf);
font.print(256 ,90-1,buf);
font.print(256 ,90+1,buf);
font.print(256+1,90-1,buf);
font.print(256+1,90 ,buf);
font.print(256+1,90+1,buf);
2001-04-02 17:48:02 +02:00
PrimDisplay();
VidSwapDraw();
}
2001-08-06 15:04:29 +02:00
font.dump();
2001-04-02 17:48:02 +02:00
ClearScreenImage();
MemFree(s_image);
2001-08-03 18:40:57 +02:00
StartLoad();
2001-08-06 15:04:29 +02:00
VSync(0);
2001-04-03 23:28:56 +02:00
}
/*****************************************************************************/
void CLevel::initLayers()
{
// Init Layers
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;
}
2001-03-05 18:04:28 +01:00
CollisionLayer=0;
2001-04-03 23:28:56 +02:00
ActorList=0;
ItemList=0;
PlatformList=0;
2001-04-09 17:35:37 +02:00
FXList=0;
2001-05-01 14:20:47 +02:00
HazardList=0;
2001-03-08 00:20:09 +01:00
2000-12-08 15:48:50 +01:00
// Back
2001-05-23 22:24:33 +02:00
if (LevelHdr->BackLayer)
2000-12-08 15:48:50 +01:00
{
sLayerHdr *Layer=(sLayerHdr*)MakePtr(LevelHdr,LevelHdr->BackLayer);
2001-04-19 01:04:03 +02:00
CLayerTile *NewLayer=new ("Back Layer") CLayerBack(LevelHdr,Layer);
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
2001-05-23 22:24:33 +02:00
if (LevelHdr->MidLayer)
2000-12-08 15:48:50 +01:00
{
sLayerHdr *Layer=(sLayerHdr*)MakePtr(LevelHdr,LevelHdr->MidLayer);
2001-04-19 01:04:03 +02:00
CLayerTile *NewLayer=new ("Mid Layer") CLayerTile(LevelHdr,Layer);
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
2001-05-23 22:24:33 +02:00
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);
2001-07-28 18:45:46 +02:00
CLayerTile *NewLayer=new ("Action Layer") CLayerTile3d(LevelHdr,Layer,m_RGBMap,m_RGBTable);
2000-12-14 17:38:34 +01:00
NewLayer->init(MapPos,0);
2000-12-09 18:22:06 +01:00
TileLayers[CLayerTile::LAYER_TILE_TYPE_ACTION]=NewLayer;
2001-08-15 16:14:13 +02:00
MapSize.vx=Layer->Width;
MapSize.vy=Layer->Height;
MapSize16.vx=Layer->Width*16;
MapSize16.vy=Layer->Height*16;
2001-08-15 18:12:20 +02:00
CThingManager::setMapWH(MapSize);
2000-12-08 15:48:50 +01:00
}
2001-02-02 20:16:49 +01:00
// Collision
2001-04-26 23:15:36 +02:00
2001-05-23 22:24:33 +02:00
if (LevelHdr->CollisionLayer)
2001-02-02 20:16:49 +01:00
{
sLayerHdr *Layer=(sLayerHdr*)MakePtr(LevelHdr,LevelHdr->CollisionLayer);
CollisionLayer=new ("Collision Layer") CLayerCollision(Layer);
2001-05-25 21:04:29 +02:00
CGameScene::setCollision(CollisionLayer);
2001-07-11 21:02:00 +02:00
CreateTileStore();
2001-02-02 20:16:49 +01:00
}
2001-04-26 23:15:36 +02:00
else
{
ASSERT(!"Where is the collision, moron!");
}
2001-07-11 21:02:00 +02:00
2001-04-02 02:17:48 +02:00
// Actors
if (LevelHdr->ActorList)
{
sThingHdr *Hdr=(sThingHdr*)MakePtr(LevelHdr,LevelHdr->ActorList);
ActorCount=Hdr->Count;
ActorList=(sThingActor**)MemAlloc(ActorCount*sizeof(sThingActor**),"Actor List");
u8 *ThingPtr=(u8*)MakePtr(Hdr,sizeof(sThingHdr));
for (int i=0; i<ActorCount; i++)
{
ActorList[i]=(sThingActor*)ThingPtr;
ThingPtr+=sizeof(sThingActor);
ThingPtr+=ActorList[i]->PointCount*sizeof(u16)*2;
}
}
2001-04-09 17:35:37 +02:00
// Platforms
if (LevelHdr->PlatformList)
{
2001-05-23 22:24:33 +02:00
2001-04-09 17:35:37 +02:00
sThingHdr *Hdr=(sThingHdr*)MakePtr(LevelHdr,LevelHdr->PlatformList);
PlatformCount=Hdr->Count;
PlatformList=(sThingPlatform**)MemAlloc(PlatformCount*sizeof(sThingPlatform**),"Platform List");
u8 *ThingPtr=(u8*)MakePtr(Hdr,sizeof(sThingHdr));
for (int i=0; i<PlatformCount; i++)
{
PlatformList[i]=(sThingPlatform*)ThingPtr;
ThingPtr+=sizeof(sThingPlatform);
ThingPtr+=PlatformList[i]->PointCount*sizeof(u16)*2;
}
}
2001-04-07 23:17:27 +02:00
// FX
if (LevelHdr->FXList)
{
sThingHdr *Hdr=(sThingHdr*)MakePtr(LevelHdr,LevelHdr->FXList);
FXCount=Hdr->Count;
FXList=(sThingFX*)MakePtr(Hdr,sizeof(sThingHdr));
}
2001-05-04 21:34:09 +02:00
2001-05-01 14:20:47 +02:00
// Hazards
if (LevelHdr->HazardList)
{
sThingHdr *Hdr=(sThingHdr*)MakePtr(LevelHdr,LevelHdr->HazardList);
HazardCount=Hdr->Count;
HazardList=(sThingHazard**)MemAlloc(HazardCount*sizeof(sThingHazard**),"Hazard List");
u8 *ThingPtr=(u8*)MakePtr(Hdr,sizeof(sThingHdr));
for (int i=0; i<HazardCount; i++)
{
HazardList[i]=(sThingHazard*)ThingPtr;
ThingPtr+=sizeof(sThingHazard);
ThingPtr+=HazardList[i]->PointCount*sizeof(u16)*2;
}
}
2001-04-03 23:28:56 +02:00
2001-05-04 21:34:09 +02:00
initThings(false);
2000-12-06 23:52:00 +01:00
}
2001-05-04 21:34:09 +02:00
/*****************************************************************************/
void CLevel::initThings(int _respawningLevel)
{
if (LevelHdr->TriggerList)
{
sThingHdr *Hdr=(sThingHdr*)MakePtr(LevelHdr,LevelHdr->TriggerList);
TriggerCount=Hdr->Count;
TriggerList=(sThingTrigger*)MakePtr(Hdr,sizeof(sThingHdr));
2001-05-29 22:31:02 +02:00
// Cam Locks first
2001-05-04 21:34:09 +02:00
for(int i=0;i<TriggerCount;i++)
{
2001-05-29 22:31:02 +02:00
if (TriggerList[i].Type==CTrigger::TRIGGER_CAMLOCK)
2001-05-04 21:34:09 +02:00
{
2001-05-29 22:31:02 +02:00
CTrigger::Create(&TriggerList[i]);
2001-05-04 21:34:09 +02:00
}
}
2001-05-29 22:31:02 +02:00
// the rest
2001-05-04 21:34:09 +02:00
TriggerList=(sThingTrigger*)MakePtr(Hdr,sizeof(sThingHdr));
for(int i=0;i<TriggerCount;i++)
{
2001-06-12 01:30:23 +02:00
if (TriggerList[i].Type!=CTrigger::TRIGGER_CAMLOCK)
2001-05-04 21:34:09 +02:00
{
2001-05-29 22:31:02 +02:00
CTrigger::Create(&TriggerList[i]);
2001-05-04 21:34:09 +02:00
}
}
}
// Items
if (LevelHdr->ItemList)
{
2001-06-01 20:59:33 +02:00
DVECTOR pos;
int itemNumber;
2001-05-04 21:34:09 +02:00
sThingHdr *Hdr=(sThingHdr*)MakePtr(LevelHdr,LevelHdr->ItemList);
ItemCount=Hdr->Count;
ItemList=(sThingItem*)MakePtr(Hdr,sizeof(sThingHdr));
2001-06-01 20:59:33 +02:00
itemNumber=0;
2001-05-04 21:34:09 +02:00
for(int i=0;i<ItemCount;i++)
{
2001-05-15 18:48:29 +02:00
int createThisPickup;
2001-06-01 20:59:33 +02:00
int isNumberedItem;
2001-05-09 22:15:01 +02:00
CBasePickup *newPickup;
2001-05-23 22:24:33 +02:00
2001-05-15 18:48:29 +02:00
createThisPickup=true;
2001-06-01 20:59:33 +02:00
isNumberedItem=false;
2001-06-14 17:19:57 +02:00
if((PICKUP_TYPE)ItemList->Type==PICKUP__KELP_TOKEN)
2001-06-01 20:59:33 +02:00
{
isNumberedItem=true;
if(CGameSlotManager::getSlotData()->isKelpTokenUncollected(GameScene.getChapterNumber()-1,GameScene.getLevelNumber()-1,itemNumber)==false)
{
createThisPickup=false;
}
2001-05-15 18:48:29 +02:00
}
2001-05-18 23:03:51 +02:00
if((PICKUP_TYPE)ItemList->Type==PICKUP__HELMET&&
2001-05-17 20:42:59 +02:00
_respawningLevel)
2001-05-15 18:48:29 +02:00
{
createThisPickup=false;
}
if(createThisPickup)
2001-05-04 21:34:09 +02:00
{
pos.vx=ItemList->Pos.X<<4;
pos.vy=ItemList->Pos.Y<<4;
2001-05-09 22:15:01 +02:00
newPickup=createPickup((PICKUP_TYPE)ItemList->Type,&pos);
2001-06-01 20:59:33 +02:00
if(isNumberedItem)
2001-05-09 22:15:01 +02:00
{
2001-06-14 17:19:57 +02:00
if((PICKUP_TYPE)ItemList->Type==PICKUP__KELP_TOKEN)
2001-06-01 20:59:33 +02:00
{
((CKelpTokenPickup*)newPickup)->setTokenNumber(itemNumber);
}
else
{
ASSERT(0);
}
2001-05-09 22:15:01 +02:00
}
}
2001-06-01 20:59:33 +02:00
if(isNumberedItem)
2001-05-09 22:15:01 +02:00
{
2001-06-01 20:59:33 +02:00
itemNumber++;
2001-05-04 21:34:09 +02:00
}
2001-05-15 18:48:29 +02:00
2001-05-04 21:34:09 +02:00
ItemList++;
}
}
// Init actors (needs moving and tidying
int actorNum;
int platformNum;
int hazardNum;
sThingActor **actorList = getActorList();
if (actorList)
{
for ( actorNum = 0 ; actorNum < getActorCount() ; actorNum++ )
{
sThingActor *ThisActor=actorList[actorNum];
CGameScene::ACTOR_TYPE actorType = CGameScene::getActorType( actorList[actorNum]->Type );
switch ( actorType )
{
case CGameScene::ACTOR_ENEMY_NPC:
{
CNpcEnemy *enemy;
enemy=CNpcEnemy::Create(ThisActor);
2001-05-09 23:27:23 +02:00
2001-07-06 16:55:58 +02:00
if ( enemy )
2001-05-09 23:27:23 +02:00
{
2001-07-06 16:55:58 +02:00
// if boss is killed and user dies, boss will not initialise and will return NULL
enemy->setupWaypoints( ThisActor );
enemy->postInit();
if ( ThisActor->Speed )
{
enemy->setSpeed( ThisActor->Speed );
}
2001-05-09 23:27:23 +02:00
}
2001-05-04 21:34:09 +02:00
}
break;
case CGameScene::ACTOR_FRIEND_NPC:
{
CNpcFriend *friendNpc;
friendNpc=CNpcFriend::Create(ThisActor);
2001-05-30 22:24:02 +02:00
friendNpc->setupWaypoints( ThisActor );
2001-05-04 21:34:09 +02:00
friendNpc->postInit();
}
break;
default:
break;
}
}
}
sThingPlatform **platformList = getPlatformList();
if (platformList)
{
for ( platformNum = 0 ; platformNum < getPlatformCount() ; platformNum++ )
{
sThingPlatform *ThisPlatform = platformList[platformNum];
CNpcPlatform *platform;
platform = CNpcPlatform::Create( ThisPlatform );
platform->postInit();
2001-05-09 23:27:23 +02:00
if ( ThisPlatform->Speed )
{
platform->setSpeed( ThisPlatform->Speed );
}
2001-05-04 21:34:09 +02:00
}
}
sThingHazard **hazardList = getHazardList();
if (hazardList)
{
for ( hazardNum = 0 ; hazardNum < getHazardCount() ; hazardNum++ )
{
sThingHazard *ThisHazard = hazardList[hazardNum];
CNpcHazard *hazard;
hazard = CNpcHazard::Create( ThisHazard );
2001-05-10 21:27:57 +02:00
if ( ThisHazard->Respawn )
{
hazard->setRespawnRate( ThisHazard->Respawn );
}
2001-05-04 21:34:09 +02:00
}
}
2001-05-10 16:09:06 +02:00
// initialise jellyfish generator
CJellyfishGenerator::init();
2001-05-11 01:51:14 +02:00
CThingManager::initAllThings();
2001-05-23 22:24:33 +02:00
CThingManager::matchWheelsAndWeights();
2001-05-24 01:16:43 +02:00
CThingManager::matchPressureSwitches();
2001-05-30 22:24:02 +02:00
CThingManager::matchGaryTriggers();
2001-05-04 21:34:09 +02:00
}
/*****************************************************************************/
void CLevel::respawnLevel()
{
2001-07-06 16:55:58 +02:00
//m_isBossRespawn = false;
//m_bossHealth = 0;
2001-05-04 23:58:41 +02:00
2001-05-04 21:34:09 +02:00
CThingManager::killAllThingsForRespawn();
initThings(true);
2001-07-11 21:02:00 +02:00
ApplyTileStore(); // Put dem tiles back
2001-05-04 21:34:09 +02:00
}
2000-12-06 23:52:00 +01:00
/*****************************************************************************/
2001-04-19 01:04:03 +02:00
void CLevel::shutdown()
2000-12-06 23:52:00 +01:00
{
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-07-28 18:45:46 +02:00
if (!LevelHdr->RGBLayer)
{
MemFree(m_RGBMap);
MemFree(m_RGBTable);
}
2001-02-12 18:18:17 +01:00
2001-03-05 18:04:28 +01:00
if (CollisionLayer)
{
2001-05-23 22:24:33 +02:00
CollisionLayer->shutdown();
2001-04-03 23:28:56 +02:00
delete CollisionLayer;
}
CSoundMediator::stopAllSound();
2001-05-22 21:48:25 +02:00
for(int i=0;i<5;i++)
{
VSync(0);CSoundMediator::think(1); // This is needed to let xmplay kill off the sounds properly (pkg)
}
2001-04-03 23:28:56 +02:00
if (ActorList) MemFree(ActorList);
2001-04-09 17:35:37 +02:00
if (PlatformList) MemFree(PlatformList);
2001-05-01 14:20:47 +02:00
if (HazardList) MemFree(HazardList);
2001-07-11 21:02:00 +02:00
if (m_TileStore) MemFree(m_TileStore);
2001-04-03 23:28:56 +02:00
2001-04-19 01:04:03 +02:00
MemFree(LevelHdr);
2001-04-25 18:41:16 +02:00
CActorPool::Reset();
2001-04-19 01:04:03 +02:00
TPFree(m_levelTPage);
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-07-31 18:49:59 +02:00
#ifdef __VERSION_DEBUG__
// Clever code to make code not so confusing!!
// Emulate a PS2 by forcing it to run in 50/60 fps...by not drawing much!!
VidSetClearScreen(PretendToBeAPS2);
if(!PretendToBeAPS2)
#endif
// Render Layers
for (int i=0; i<CLayerTile::LAYER_TILE_TYPE_MAX; i++)
{
if (TileLayers[i]) TileLayers[i]->render();
}
2001-04-26 23:15:36 +02:00
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)
{
2001-04-26 23:15:36 +02: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
}
2001-02-12 16:26:00 +01:00
/*****************************************************************************/
/*****************************************************************************/
/*****************************************************************************/
2001-08-15 16:14:13 +02:00
/*
2001-02-12 16:26:00 +01:00
DVECTOR CLevel::getMapSize()
{
2001-04-03 23:28:56 +02:00
DVECTOR size;
sLayerHdr *layer;
2001-02-12 16:26:00 +01:00
2001-04-03 23:28:56 +02:00
layer=(sLayerHdr*)MakePtr(LevelHdr,LevelHdr->ActionLayer);
size.vx=layer->Width;
size.vy=layer->Height;
2001-02-12 16:26:00 +01:00
2001-04-03 23:28:56 +02:00
return size;
2001-02-12 16:26:00 +01:00
}
2001-08-15 16:14:13 +02:00
*/
2001-02-12 16:26:00 +01:00
2001-05-03 00:49:59 +02:00
/*****************************************************************************/
/*****************************************************************************/
/*****************************************************************************/
2001-08-21 16:44:16 +02:00
void CLevel::destroyMapArea(DVECTOR const &Pos,int ColT)
2001-05-03 00:49:59 +02:00
{
2001-05-16 21:06:47 +02:00
DVECTOR TL,BR;
2001-08-21 16:44:16 +02:00
//const int ColT=COLLISION_TYPE_DESTRUCTABLE_WALL;
2001-05-03 00:49:59 +02:00
2001-05-16 21:06:47 +02:00
TL.vx=Pos.vx&-16;;
TL.vy=Pos.vy&-16;;
BR=TL;
// Left
while (CollisionLayer->getCollisionBlock(TL.vx-16,TL.vy)>>COLLISION_TYPE_FLAG_SHIFT==ColT) TL.vx-=16;
// Top
while (CollisionLayer->getCollisionBlock(TL.vx,TL.vy-16)>>COLLISION_TYPE_FLAG_SHIFT==ColT) TL.vy-=16;
// Right
while (CollisionLayer->getCollisionBlock(BR.vx+16,BR.vy)>>COLLISION_TYPE_FLAG_SHIFT==ColT) BR.vx+=16;
// Bottom
while (CollisionLayer->getCollisionBlock(BR.vx,BR.vy+16)>>COLLISION_TYPE_FLAG_SHIFT==ColT) BR.vy+=16;
DVECTOR DP;
2001-05-23 22:24:33 +02:00
2001-05-16 21:06:47 +02:00
for (DP.vy=TL.vy; DP.vy<=BR.vy; DP.vy+=16)
{
for (DP.vx=TL.vx; DP.vx<=BR.vx; DP.vx+=16)
{
u8 *ColElem=CollisionLayer->getMapPtr(DP.vx,DP.vy);
2001-05-16 22:10:46 +02:00
if (*ColElem>>COLLISION_TYPE_FLAG_SHIFT==ColT)
2001-05-16 21:06:47 +02:00
{
sTileMapElem *MapElem=TileLayers[CLayerTile::LAYER_TILE_TYPE_ACTION]->getMapPtr(DP.vx,DP.vy);
2001-08-21 16:44:16 +02:00
if (MapElem->Tile)
{
CFXFallingTile *FX=(CFXFallingTile*)CFX::Create(CFX::FX_TYPE_FALLINGTILE,DP);
FX->SetTile(MapElem->Tile);
MapElem->Tile=0;
}
2001-05-16 21:06:47 +02:00
*ColElem=0;
}
}
}
2001-05-03 00:49:59 +02:00
}
2001-06-19 00:20:45 +02:00
/*****************************************************************************/
2001-06-20 21:06:35 +02:00
// fixed now, so takes out whole vertical section, wherever it is hit
// Note: relies on tiles not being top or bottom of map tho!!
2001-08-21 16:44:16 +02:00
void CLevel::destroyMapTile(DVECTOR const &Pos,int ColT)
2001-06-19 00:20:45 +02:00
{
2001-08-15 17:05:44 +02:00
int Width=getMapWidth();
2001-06-20 21:06:35 +02:00
DVECTOR MP=Pos;
2001-08-21 16:44:16 +02:00
//const int ColT=COLLISION_TYPE_DESTRUCTABLE_FLOOR;
2001-06-20 21:06:35 +02:00
// Goto Top
while (*CollisionLayer->getMapPtr(MP.vx,MP.vy-1)>>COLLISION_TYPE_FLAG_SHIFT==ColT)
{
MP.vy-=16;
}
2001-06-19 00:20:45 +02:00
2001-06-20 21:06:35 +02:00
u8 *ColElem=CollisionLayer->getMapPtr(MP.vx,MP.vy);
sTileMapElem *MapElem=TileLayers[CLayerTile::LAYER_TILE_TYPE_ACTION]->getMapPtr(MP.vx,MP.vy);
2001-06-19 00:20:45 +02:00
2001-06-20 21:06:35 +02:00
// Thrash em down
2001-06-19 00:20:45 +02:00
while (*ColElem>>COLLISION_TYPE_FLAG_SHIFT==ColT)
{
2001-08-21 16:44:16 +02:00
if (MapElem->Tile)
{
CFXFallingTile *FX=(CFXFallingTile*)CFX::Create(CFX::FX_TYPE_FALLINGTILE,MP);
FX->SetTile(MapElem->Tile);
MapElem->Tile=0;
}
2001-06-19 00:20:45 +02:00
*ColElem=0;
MapElem+=Width;
ColElem+=Width;
MP.vy+=16;
}
}
2001-05-03 00:49:59 +02:00
2001-06-06 22:23:44 +02:00
/*****************************************************************************/
/*****************************************************************************/
/*****************************************************************************/
2001-07-11 20:15:41 +02:00
void CLevel::reverseMapConveyor()
2001-06-06 22:23:44 +02:00
{
2001-07-11 20:15:41 +02:00
DVECTOR size = getMapSize();
int ColT;
2001-06-06 22:23:44 +02:00
DVECTOR DP;
2001-07-11 20:15:41 +02:00
for (DP.vy=0; DP.vy<=(size.vy<<4); DP.vy+=16)
2001-06-06 22:23:44 +02:00
{
2001-07-11 20:15:41 +02:00
for (DP.vx=0; DP.vx<=(size.vx<<4); DP.vx+=16)
2001-06-06 22:23:44 +02:00
{
u8 *ColElem=CollisionLayer->getMapPtr(DP.vx,DP.vy);
2001-07-11 20:15:41 +02:00
if ( (*ColElem)>>COLLISION_TYPE_FLAG_SHIFT == COLLISION_TYPE_MOVE_LEFT )
2001-06-06 22:23:44 +02:00
{
2001-07-11 20:15:41 +02:00
*ColElem &= ~COLLISION_TYPE_FLAG_MOVE_LEFT;
*ColElem |= COLLISION_TYPE_FLAG_MOVE_RIGHT;
}
else if ( (*ColElem)>>COLLISION_TYPE_FLAG_SHIFT == COLLISION_TYPE_MOVE_RIGHT )
{
*ColElem &= ~COLLISION_TYPE_FLAG_MOVE_RIGHT;
*ColElem |= COLLISION_TYPE_FLAG_MOVE_LEFT;
2001-06-06 22:23:44 +02:00
}
}
}
}
2001-07-11 21:02:00 +02:00
/*****************************************************************************/
/*****************************************************************************/
/*****************************************************************************/
2001-08-21 16:44:16 +02:00
// note: slippery used as special type in 4:4 boss arena
2001-07-11 21:02:00 +02:00
void CLevel::CreateTileStore()
{
2001-08-15 17:05:44 +02:00
int MapW=getMapWidth();
int MapH=getMapHeight();
2001-07-11 21:02:00 +02:00
int X,Y;
m_TileStoreCount=0;
m_TileStore=0;
// CountEm
for (Y=0; Y<MapH; Y++)
{
for (X=0; X<MapW; X++)
{
u8 *ColElem=CollisionLayer->getMapPtr(X*16,Y*16);
int ColT = (*ColElem) & COLLISION_TYPE_MASK;
2001-08-21 16:44:16 +02:00
if ( ColT==COLLISION_TYPE_FLAG_DESTRUCTABLE_FLOOR || ColT==COLLISION_TYPE_FLAG_DESTRUCTABLE_WALL || ColT==COLLISION_TYPE_FLAG_SLIPPERY)
2001-07-11 21:02:00 +02:00
{
m_TileStoreCount++;
}
}
}
// StoreEm
if (m_TileStoreCount)
{
m_TileStore=(sTileStore*)MemAlloc(m_TileStoreCount*sizeof(sTileStore),"TileStoreList");
sTileStore *Ptr=m_TileStore;
for (Y=0; Y<MapH; Y++)
{
for (X=0; X<MapW; X++)
{
u8 *ColElem=CollisionLayer->getMapPtr(X*16,Y*16);
int ColT = (*ColElem) & COLLISION_TYPE_MASK;
2001-08-21 16:44:16 +02:00
if ( ColT==COLLISION_TYPE_FLAG_DESTRUCTABLE_FLOOR || ColT==COLLISION_TYPE_FLAG_DESTRUCTABLE_WALL || ColT==COLLISION_TYPE_FLAG_SLIPPERY)
2001-07-11 21:02:00 +02:00
{
Ptr->X=X;
Ptr->Y=Y;
Ptr->Col=*ColElem;
Ptr->Tile=*TileLayers[CLayerTile::LAYER_TILE_TYPE_ACTION]->getMapPtr(X*16,Y*16);
Ptr++;
}
}
}
}
}
/*****************************************************************************/
void CLevel::ApplyTileStore()
{
sTileStore *Ptr=m_TileStore;
for (int i=0; i<m_TileStoreCount; i++)
{
u8 *ColElem=CollisionLayer->getMapPtr(Ptr->X*16,Ptr->Y*16);
sTileMapElem *MapElem=TileLayers[CLayerTile::LAYER_TILE_TYPE_ACTION]->getMapPtr(Ptr->X*16,Ptr->Y*16);
*ColElem=Ptr->Col;
*MapElem=Ptr->Tile;
Ptr++;
}
}