This commit is contained in:
Charles 2001-05-01 13:28:11 +00:00
parent 17a78fdd73
commit 1f1174bcc5
8 changed files with 241 additions and 33 deletions

View File

@ -35,6 +35,10 @@
#include "platform\platform.h"
#endif
#ifndef __HAZARD_HAZARD_H__
#include "hazard\hazard.h"
#endif
#ifndef __PROJECTL_PROJECTL_H__
#include "projectl\projectl.h"
#endif
@ -309,6 +313,7 @@ void CGameScene::initLevel()
// Init actors (needs moving and tidying
int actorNum;
int platformNum;
int hazardNum;
sThingActor **actorList = Level.getActorList();
if (actorList)
@ -356,6 +361,18 @@ void CGameScene::initLevel()
}
}
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
// better timing over when it starts (pkg)
CSoundMediator::playSong();

View File

@ -23,22 +23,143 @@
#include "system\vid.h"
#endif
#ifndef __UTILS_HEADER__
#include "utils\utils.h"
#endif
#ifndef __HAZARD_HFALLING_H__
#include "hazard\hfalling.h"
#endif
#ifndef __HAZARD_HPENDULM_H__
#include "hazard\hpendulm.h"
#endif
#ifndef __HAZARD_HBOAT_H__
#include "hazard\hboat.h"
#endif
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
CNpcHazard::NPC_HAZARD_UNIT_TYPE CNpcHazard::mapEditConvertTable[NPC_HAZARD_TYPE_MAX] =
{
NPC_FALLING_HAZARD,
NPC_PENDULUM_HAZARD,
NPC_BOAT_HAZARD,
};
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
CNpcHazard *CNpcHazard::Create(sThingHazard *ThisHazard)
{
CNpcHazard *hazard;
NPC_HAZARD_UNIT_TYPE hazardType = getTypeFromMapEdit( ThisHazard->Type );
switch( hazardType )
{
case NPC_FALLING_HAZARD:
{
hazard = new ("falling hazard") CNpcFallingHazard;
break;
}
case NPC_PENDULUM_HAZARD:
{
hazard = new ("pendulum hazard") CNpcPendulumHazard;
break;
}
case NPC_BOAT_HAZARD:
{
hazard = new ("boat hazard") CNpcBoatHazard;
break;
}
default:
{
hazard = NULL;
break;
}
}
ASSERT( hazard );
hazard->init();
hazard->setWaypoints( ThisHazard );
hazard->setGraphic( ThisHazard );
return( hazard );
}
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
void CNpcHazard::setWaypoints( sThingHazard *ThisHazard )
{
int pointNum;
u16 *PntList=(u16*)MakePtr(ThisHazard,sizeof(sThingHazard));
u16 newXPos, newYPos;
newXPos = (u16) *PntList;
PntList++;
newYPos = (u16) *PntList;
PntList++;
DVECTOR startPos;
startPos.vx = newXPos << 4;
startPos.vy = newYPos << 4;
Pos = startPos;
m_base = Pos;
addWaypoint( newXPos, newYPos );
if ( ThisHazard->PointCount > 1 )
{
for ( pointNum = 1 ; pointNum < ThisHazard->PointCount ; pointNum++ )
{
newXPos = (u16) *PntList;
PntList++;
newYPos = (u16) *PntList;
PntList++;
addWaypoint( newXPos, newYPos );
}
}
}
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
void CNpcHazard::addWaypoint( s32 xPos, s32 yPos )
{
DVECTOR newPos;
newPos.vx = xPos << 4;
newPos.vy = yPos << 4;
m_npcPath.addWaypoint( newPos );
}
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
CNpcHazard::NPC_HAZARD_UNIT_TYPE CNpcHazard::getTypeFromMapEdit( u16 newType )
{
return( mapEditConvertTable[newType] );
}
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
void CNpcHazard::init()
{
CHazardThing::init();
m_actorGfx=CActorPool::GetActor( (FileEquate) ACTORS_CLAM_SBK );
m_spriteBank=0;
//m_actorGfx=CActorPool::GetActor( (FileEquate) ACTORS_CLAM_SBK );
//m_spriteBank=0;
m_npcPath.initPath();
Pos.vx = 300;
Pos.vy = 300;
m_base = Pos;
m_timer = 0;
m_timerActive = false;
m_isActive = true;
@ -50,14 +171,23 @@ void CNpcHazard::init()
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
void CNpcHazard::setGraphic( sThingHazard *ThisHazard )
{
m_modelGfx = new ("ModelGfx") CModelGfx;
m_modelGfx->SetModel( ThisHazard->Gfx );
}
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
void CNpcHazard::shutdown()
{
if (m_spriteBank) m_spriteBank->dump(); delete m_spriteBank;
delete m_modelGfx;
//if (m_spriteBank) m_spriteBank->dump(); delete m_spriteBank;
// remove waypoints
m_npcPath.removeAllWaypoints();
if (m_actorGfx) delete m_actorGfx;
//if (m_actorGfx) delete m_actorGfx;
CHazardThing::shutdown();
}
@ -119,7 +249,8 @@ void CNpcHazard::render()
{
if ( renderPos.vy >= 0 && renderPos.vy <= VidGetScrH() )
{
m_actorGfx->Render(renderPos,0,0,0);
m_modelGfx->Render(renderPos);
//m_actorGfx->Render(renderPos,0,0,0);
}
}
}

View File

@ -34,11 +34,26 @@
class CNpcHazard : public CHazardThing
{
public:
enum NPC_HAZARD_UNIT_TYPE
{
NPC_FALLING_HAZARD = 0,
NPC_PENDULUM_HAZARD = 1,
NPC_BOAT_HAZARD,
NPC_HAZARD_TYPE_MAX,
};
virtual void init();
void setGraphic( sThingHazard *ThisHazard );
void shutdown();
void think(int _frames);
void render();
void setLayerCollision( class CLayerCollision *_layer ) {m_layerCollision=_layer;}
virtual void setWaypoints( sThingHazard *ThisHazard );
void addWaypoint( s32 xPos, s32 yPos );
static NPC_HAZARD_UNIT_TYPE getTypeFromMapEdit( u16 newType );
static CNpcHazard *Create(sThingHazard *ThisHazard);
protected:
enum
@ -54,8 +69,8 @@ protected:
virtual void processMovement( int _frames );
virtual void processTimer( int _frames );
CNpcPath m_npcPath;
CActorGfx *m_actorGfx;
SpriteBank *m_spriteBank;
//CActorGfx *m_actorGfx;
//SpriteBank *m_spriteBank;
DVECTOR m_base;
s32 m_timer;
bool m_timerActive;
@ -64,6 +79,9 @@ protected:
s32 m_extension;
bool m_extendDir;
s32 m_heading;
CModelGfx *m_modelGfx;
static NPC_HAZARD_UNIT_TYPE mapEditConvertTable[NPC_HAZARD_TYPE_MAX];
};
#endif

View File

@ -25,22 +25,6 @@ void CNpcBoatHazard::init()
{
CNpcHazard::init();
DVECTOR newPos;
Pos.vx = 100;
Pos.vy = 100;
m_base = Pos;
newPos.vx = 600;
newPos.vy = 100;
m_npcPath.addWaypoint( newPos );
newPos.vx = 50;
newPos.vy = 100;
m_npcPath.addWaypoint( newPos );
m_npcPath.setPathType( CNpcPath::PONG_PATH );
}

View File

@ -15,6 +15,10 @@
#include "hazard\hpendulm.h"
#endif
#ifndef __UTILS_HEADER__
#include "utils\utils.h"
#endif
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
void CNpcPendulumHazard::init()
@ -29,11 +33,58 @@ void CNpcPendulumHazard::init()
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
void CNpcPendulumHazard::setWaypoints( sThingHazard *ThisHazard )
{
int pointNum;
u16 *PntList=(u16*)MakePtr(ThisHazard,sizeof(sThingHazard));
u16 newXPos, newYPos;
newXPos = (u16) *PntList;
PntList++;
newYPos = (u16) *PntList;
PntList++;
DVECTOR startPos;
startPos.vx = newXPos << 4;
startPos.vy = newYPos << 4;
if ( ThisHazard->PointCount > 1 )
{
newXPos = (u16) *PntList;
PntList++;
newYPos = (u16) *PntList;
PntList++;
DVECTOR pivotPos;
pivotPos.vx = newXPos << 4;
pivotPos.vy = newYPos << 4;
s32 xDist = startPos.vx - pivotPos.vx;
s32 yDist = startPos.vy - pivotPos.vy;
m_maxExtension = 1024 - ratan2( abs( yDist ), abs( xDist ) );
m_length = isqrt2( ( xDist * xDist ) + ( yDist * yDist ) );
Pos = pivotPos;
}
else
{
Pos = startPos;
}
m_base = Pos;
}
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
void CNpcPendulumHazard::processMovement( int _frames )
{
if ( m_extendDir == EXTEND_LEFT )
{
if ( m_extension > 512 )
if ( m_extension > m_maxExtension )
{
m_extendDir = EXTEND_RIGHT;
}
@ -44,7 +95,7 @@ void CNpcPendulumHazard::processMovement( int _frames )
}
else
{
if ( m_extension < -512 )
if ( m_extension < -m_maxExtension )
{
m_extendDir = EXTEND_LEFT;
}

View File

@ -23,9 +23,11 @@ class CNpcPendulumHazard : public CNpcHazard
public:
void init();
protected:
virtual void setWaypoints( sThingHazard *ThisHazard );
void processMovement( int _frames );
s32 m_length;
s32 m_maxExtension;
};
#endif

View File

@ -100,6 +100,11 @@ Restart_Point=1
Ch1L1_Plat1=0
Ch1L1_Plat2=1
################################################
# Hazards
[Hazard]
Acorn=0
HeartPendulum=1
Tugboat=2

View File

@ -22,7 +22,7 @@ Respawn=1
[HeartPendulum]
Gfx=..\..\graphics\hazards\HeartPendulum\HeartPendulum.gin
WayPoints=0
WayPoints=1
Speed=0
TurnRate=0
Collision=0
@ -32,7 +32,7 @@ Respawn=2
[Tugboat]
Gfx=..\..\graphics\hazards\Tugboat\Tugboat.gin
WayPoints=0
WayPoints=16
Speed=0
TurnRate=0
Collision=0