This commit is contained in:
parent
99e98162fe
commit
77bbfc2c16
7 changed files with 233 additions and 148 deletions
|
@ -281,6 +281,13 @@ CPlayer * CGameScene::getPlayer()
|
||||||
return( m_player );
|
return( m_player );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*****************************************************************************/
|
||||||
|
void CGameScene::respawnLevel()
|
||||||
|
{
|
||||||
|
Level.respawnLevel();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
void CGameScene::sendEvent( GAME_EVENT evt, CThing *sourceThing )
|
void CGameScene::sendEvent( GAME_EVENT evt, CThing *sourceThing )
|
||||||
{
|
{
|
||||||
|
@ -313,70 +320,6 @@ void CGameScene::initLevel()
|
||||||
m_player->setHealthType(CPlayer::HEALTH_TYPE__OUT_OF_WATER);
|
m_player->setHealthType(CPlayer::HEALTH_TYPE__OUT_OF_WATER);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Init actors (needs moving and tidying
|
|
||||||
int actorNum;
|
|
||||||
int platformNum;
|
|
||||||
int hazardNum;
|
|
||||||
|
|
||||||
sThingActor **actorList = Level.getActorList();
|
|
||||||
if (actorList)
|
|
||||||
{
|
|
||||||
for ( actorNum = 0 ; actorNum < Level.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);
|
|
||||||
enemy->setLayerCollision( Level.getCollisionLayer() );
|
|
||||||
enemy->setupWaypoints( ThisActor );
|
|
||||||
enemy->postInit();
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
|
|
||||||
case CGameScene::ACTOR_FRIEND_NPC:
|
|
||||||
{
|
|
||||||
CNpcFriend *friendNpc;
|
|
||||||
friendNpc=CNpcFriend::Create(ThisActor);
|
|
||||||
friendNpc->setLayerCollision( Level.getCollisionLayer() );
|
|
||||||
friendNpc->postInit();
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
|
|
||||||
default:
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
sThingPlatform **platformList = Level.getPlatformList();
|
|
||||||
if (platformList)
|
|
||||||
{
|
|
||||||
for ( platformNum = 0 ; platformNum < Level.getPlatformCount() ; platformNum++ )
|
|
||||||
{
|
|
||||||
sThingPlatform *ThisPlatform = platformList[platformNum];
|
|
||||||
CNpcPlatform *platform;
|
|
||||||
platform = CNpcPlatform::Create( ThisPlatform );
|
|
||||||
platform->setLayerCollision( Level.getCollisionLayer() );
|
|
||||||
platform->postInit();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
sThingHazard **hazardList = Level.getHazardList();
|
|
||||||
if (hazardList)
|
|
||||||
{
|
|
||||||
for ( hazardNum = 0 ; hazardNum < Level.getHazardCount() ; hazardNum++ )
|
|
||||||
{
|
|
||||||
sThingHazard *ThisHazard = hazardList[hazardNum];
|
|
||||||
CNpcHazard *hazard;
|
|
||||||
hazard = CNpcHazard::Create( ThisHazard );
|
|
||||||
hazard->setLayerCollision( Level.getCollisionLayer() );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Song is loaded/dumped by the level, and played from here. This just gives some
|
// Song is loaded/dumped by the level, and played from here. This just gives some
|
||||||
// better timing over when it starts (pkg)
|
// better timing over when it starts (pkg)
|
||||||
CSoundMediator::playSong();
|
CSoundMediator::playSong();
|
||||||
|
|
|
@ -40,6 +40,7 @@ virtual int canPause();
|
||||||
char *getSceneName() {return "Game";}
|
char *getSceneName() {return "Game";}
|
||||||
|
|
||||||
CPlayer *getPlayer();
|
CPlayer *getPlayer();
|
||||||
|
void respawnLevel();
|
||||||
void sendEvent( GAME_EVENT evt, class CThing *sourceThing );
|
void sendEvent( GAME_EVENT evt, class CThing *sourceThing );
|
||||||
|
|
||||||
static void setReadyToExit() {s_readyToExit=true;}
|
static void setReadyToExit() {s_readyToExit=true;}
|
||||||
|
|
|
@ -47,9 +47,29 @@
|
||||||
#include "system\vid.h"
|
#include "system\vid.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include "enemy\npc.h"
|
|
||||||
#include "gfx\actor.h"
|
#include "gfx\actor.h"
|
||||||
|
|
||||||
|
#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
|
||||||
|
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
extern int s_globalLevelSelectThing;
|
extern int s_globalLevelSelectThing;
|
||||||
|
|
||||||
|
@ -264,21 +284,6 @@ void CLevel::initLayers()
|
||||||
ThingPtr+=ActorList[i]->PointCount*sizeof(u16)*2;
|
ThingPtr+=ActorList[i]->PointCount*sizeof(u16)*2;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// Items
|
|
||||||
if (LevelHdr->ItemList)
|
|
||||||
{
|
|
||||||
sThingHdr *Hdr=(sThingHdr*)MakePtr(LevelHdr,LevelHdr->ItemList);
|
|
||||||
ItemCount=Hdr->Count;
|
|
||||||
ItemList=(sThingItem*)MakePtr(Hdr,sizeof(sThingHdr));
|
|
||||||
DVECTOR pos;
|
|
||||||
for(int i=0;i<ItemCount;i++)
|
|
||||||
{
|
|
||||||
pos.vx=ItemList->Pos.X<<4;
|
|
||||||
pos.vy=ItemList->Pos.Y<<4;
|
|
||||||
createPickup((PICKUP_TYPE)ItemList->Type,&pos);
|
|
||||||
ItemList++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// Platforms
|
// Platforms
|
||||||
if (LevelHdr->PlatformList)
|
if (LevelHdr->PlatformList)
|
||||||
{
|
{
|
||||||
|
@ -295,8 +300,39 @@ void CLevel::initLayers()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Triggers
|
// FX
|
||||||
// Yeah yeah - I'll put this crap into a seperate file when the numbers of trigger types get a bit bigger! (pkg)
|
if (LevelHdr->FXList)
|
||||||
|
{
|
||||||
|
sThingHdr *Hdr=(sThingHdr*)MakePtr(LevelHdr,LevelHdr->FXList);
|
||||||
|
FXCount=Hdr->Count;
|
||||||
|
FXList=(sThingFX*)MakePtr(Hdr,sizeof(sThingHdr));
|
||||||
|
}
|
||||||
|
|
||||||
|
// 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;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
initThings(false);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/*****************************************************************************/
|
||||||
|
void CLevel::initThings(int _respawningLevel)
|
||||||
|
{
|
||||||
|
// Triggers
|
||||||
|
// Yeah yeah - I'll put this crap into a seperate file when the numbers of trigger types get a bit bigger! (pkg)
|
||||||
if (LevelHdr->TriggerList)
|
if (LevelHdr->TriggerList)
|
||||||
{
|
{
|
||||||
sThingHdr *Hdr=(sThingHdr*)MakePtr(LevelHdr,LevelHdr->TriggerList);
|
sThingHdr *Hdr=(sThingHdr*)MakePtr(LevelHdr,LevelHdr->TriggerList);
|
||||||
|
@ -360,30 +396,101 @@ void CLevel::initLayers()
|
||||||
TriggerList++;
|
TriggerList++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// FX
|
|
||||||
if (LevelHdr->FXList)
|
// Items
|
||||||
|
if (LevelHdr->ItemList)
|
||||||
{
|
{
|
||||||
sThingHdr *Hdr=(sThingHdr*)MakePtr(LevelHdr,LevelHdr->FXList);
|
sThingHdr *Hdr=(sThingHdr*)MakePtr(LevelHdr,LevelHdr->ItemList);
|
||||||
FXCount=Hdr->Count;
|
ItemCount=Hdr->Count;
|
||||||
FXList=(sThingFX*)MakePtr(Hdr,sizeof(sThingHdr));
|
ItemList=(sThingItem*)MakePtr(Hdr,sizeof(sThingHdr));
|
||||||
|
DVECTOR pos;
|
||||||
|
for(int i=0;i<ItemCount;i++)
|
||||||
|
{
|
||||||
|
if(!(_respawningLevel&&(PICKUP_TYPE)ItemList->Type==PICKUP__SPATULA))
|
||||||
|
{
|
||||||
|
pos.vx=ItemList->Pos.X<<4;
|
||||||
|
pos.vy=ItemList->Pos.Y<<4;
|
||||||
|
createPickup((PICKUP_TYPE)ItemList->Type,&pos);
|
||||||
}
|
}
|
||||||
// Hazards
|
ItemList++;
|
||||||
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;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 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);
|
||||||
|
enemy->setLayerCollision( getCollisionLayer() );
|
||||||
|
enemy->setupWaypoints( ThisActor );
|
||||||
|
enemy->postInit();
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
case CGameScene::ACTOR_FRIEND_NPC:
|
||||||
|
{
|
||||||
|
CNpcFriend *friendNpc;
|
||||||
|
friendNpc=CNpcFriend::Create(ThisActor);
|
||||||
|
friendNpc->setLayerCollision( getCollisionLayer() );
|
||||||
|
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->setLayerCollision( getCollisionLayer() );
|
||||||
|
platform->postInit();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
sThingHazard **hazardList = getHazardList();
|
||||||
|
if (hazardList)
|
||||||
|
{
|
||||||
|
for ( hazardNum = 0 ; hazardNum < getHazardCount() ; hazardNum++ )
|
||||||
|
{
|
||||||
|
sThingHazard *ThisHazard = hazardList[hazardNum];
|
||||||
|
CNpcHazard *hazard;
|
||||||
|
hazard = CNpcHazard::Create( ThisHazard );
|
||||||
|
hazard->setLayerCollision( getCollisionLayer() );
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/*****************************************************************************/
|
||||||
|
void CLevel::respawnLevel()
|
||||||
|
{
|
||||||
|
CThingManager::killAllThingsForRespawn();
|
||||||
|
initThings(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
void CLevel::shutdown()
|
void CLevel::shutdown()
|
||||||
{
|
{
|
||||||
|
|
|
@ -50,8 +50,13 @@ public:
|
||||||
|
|
||||||
bool GetNextLevel(int &Lvl);
|
bool GetNextLevel(int &Lvl);
|
||||||
|
|
||||||
|
void respawnLevel();
|
||||||
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void initLayers();
|
void initLayers();
|
||||||
|
void initThings(int _respawningLevel);
|
||||||
|
|
||||||
void DisplayLoadingScreen(sLvlTab *lvlTab);
|
void DisplayLoadingScreen(sLvlTab *lvlTab);
|
||||||
|
|
||||||
sLevelHdr *LevelHdr;
|
sLevelHdr *LevelHdr;
|
||||||
|
|
|
@ -77,9 +77,9 @@
|
||||||
#include "platform\platform.h"
|
#include "platform\platform.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifndef __GAME_GAME_H__
|
||||||
// to be removed
|
#include "game\game.h"
|
||||||
//#include "gfx\tpage.h"
|
#endif
|
||||||
|
|
||||||
|
|
||||||
/* Std Lib
|
/* Std Lib
|
||||||
|
@ -1304,6 +1304,8 @@ void CPlayer::respawn()
|
||||||
m_moveVelocity.vx=m_moveVelocity.vy=0;
|
m_moveVelocity.vx=m_moveVelocity.vy=0;
|
||||||
|
|
||||||
clearPlatform();
|
clearPlatform();
|
||||||
|
|
||||||
|
GameScene.respawnLevel();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -97,6 +97,32 @@ void CThingManager::shutdown()
|
||||||
s_initialised=false;
|
s_initialised=false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*----------------------------------------------------------------------
|
||||||
|
Function:
|
||||||
|
Purpose: Kills every CThing except the player
|
||||||
|
Params:
|
||||||
|
Returns:
|
||||||
|
---------------------------------------------------------------------- */
|
||||||
|
void CThingManager::killAllThingsForRespawn()
|
||||||
|
{
|
||||||
|
int i;
|
||||||
|
CThing *thing;
|
||||||
|
|
||||||
|
ASSERT(s_initialised);
|
||||||
|
for(i=0;i<CThing::MAX_TYPE;i++)
|
||||||
|
{
|
||||||
|
if(i!=CThing::TYPE_PLAYER)
|
||||||
|
{
|
||||||
|
while(s_thingLists[i])
|
||||||
|
{
|
||||||
|
thing=s_thingLists[i];
|
||||||
|
thing->shutdown();
|
||||||
|
delete thing;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/*----------------------------------------------------------------------
|
/*----------------------------------------------------------------------
|
||||||
Function:
|
Function:
|
||||||
Purpose:
|
Purpose:
|
||||||
|
|
|
@ -52,6 +52,7 @@ class CThingManager
|
||||||
public:
|
public:
|
||||||
static void init();
|
static void init();
|
||||||
static void shutdown();
|
static void shutdown();
|
||||||
|
static void killAllThingsForRespawn();
|
||||||
|
|
||||||
static void thinkAllThings(int _frames);
|
static void thinkAllThings(int _frames);
|
||||||
static void renderAllThings();
|
static void renderAllThings();
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue