This commit is contained in:
Charles 2001-05-23 23:08:26 +00:00
parent 7f0b5ae662
commit ec8ff7ed5b
4 changed files with 374 additions and 0 deletions

106
source/hazard/hpswitch.cpp Normal file
View File

@ -0,0 +1,106 @@
/*=========================================================================
hpswitch.cpp
Author: CRB
Created:
Project: Spongebob
Purpose:
Copyright (c) 2001 Climax Development Ltd
===========================================================================*/
#ifndef __HAZARD_HPSWITCH_H__
#include "hazard\hpswitch.h"
#endif
#ifndef __UTILS_HEADER__
#include "utils\utils.h"
#endif
#ifndef __PLAYER_PLAYER_H__
#include "player\player.h"
#endif
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
void CNpcPressureSwitchHazard::init()
{
CNpcHazard::init();
m_rotation = 0;
}
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
void CNpcPressureSwitchHazard::setWaypoints( sThingHazard *ThisHazard )
{
u16 *PntList=(u16*)MakePtr(ThisHazard,sizeof(sThingHazard));
u16 newXPos, newYPos;
// get init pos
newXPos = (u16) *PntList;
PntList++;
newYPos = (u16) *PntList;
PntList++;
m_triggerPos.vx = newXPos;
m_triggerPos.vy = newYPos;
DVECTOR startPos;
startPos.vx = newXPos << 4;
startPos.vy = newYPos << 4;
Pos = startPos;
m_base = Pos;
}
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
void CNpcPressureSwitchHazard::collidedWith( CThing *_thisThing )
{
if ( m_isActive )
{
switch(_thisThing->getThingType())
{
case TYPE_PLAYER:
{
m_platform->setTriggered();
break;
}
default:
ASSERT(0);
break;
}
}
}
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/*void CNpcRisingWeightWheelHazard::render()
{
CHazardThing::render();
if (canRender())
{
DVECTOR &renderPos=getRenderPos();
SVECTOR rotation;
rotation.vx = 0;
rotation.vy = 0;
rotation.vz = m_rotation;
VECTOR scale;
scale.vx = ONE;
scale.vy = ONE;
scale.vz = ONE;
m_modelGfx->Render(renderPos,&rotation,&scale);
}
}*/

41
source/hazard/hpswitch.h Normal file
View File

@ -0,0 +1,41 @@
/*=========================================================================
hpswitch.h
Author: CRB
Created:
Project: Spongebob
Purpose:
Copyright (c) 2001 Climax Development Ltd
===========================================================================*/
#ifndef __HAZARD_HPSWITCH_H__
#define __HAZARD_HPSWITCH_H__
#ifndef __HAZARD_HAZARD_H__
#include "hazard\hazard.h"
#endif
#ifndef __PLATFORM_PTRPDOOR_H__
#include "platform\ptrpdoor.h"
#endif
class CNpcPressureSwitchHazard : public CNpcHazard
{
public:
void init();
DVECTOR const &getTriggerPos() {return( m_triggerPos );}
void linkToPlatform( CNpcTrapdoorPlatform *platform ) {m_platform = platform;}
//virtual void render();
protected:
virtual void setWaypoints( sThingHazard *ThisHazard );
virtual void collidedWith(CThing *_thisThing);
DVECTOR m_triggerPos;
CNpcTrapdoorPlatform *m_platform;
s16 m_rotation;
};
#endif

View File

@ -0,0 +1,190 @@
/*=========================================================================
ptrpdoor.cpp
Author: CRB
Created:
Project: Spongebob
Purpose:
Copyright (c) 2001 Climax Development Ltd
===========================================================================*/
#ifndef __PLATFORM_PTRPDOOR_H__
#include "platform\ptrpdoor.h"
#endif
#ifndef __UTILS_HEADER__
#include "utils\utils.h"
#endif
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
void CNpcTrapdoorPlatform::postInit()
{
CNpcPlatform::postInit();
m_triggered = false;
if ( m_pointRight )
{
setCollisionAngle( 1024 );
}
else
{
setCollisionAngle( -1024 );
}
}
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
void CNpcTrapdoorPlatform::setWaypoints( sThingPlatform *ThisPlatform )
{
ASSERT( ThisPlatform->PointCount == 3 );
u16 *PntList=(u16*)MakePtr(ThisPlatform,sizeof(sThingPlatform));
u16 newXPos, newYPos;
// get master hazard init pos
newXPos = (u16) *PntList;
PntList++;
newYPos = (u16) *PntList;
PntList++;
DVECTOR startPos;
startPos.vx = newXPos << 4;
startPos.vy = newYPos << 4;
Pos = startPos;
m_base = Pos;
init( startPos );
// skip next
newXPos = (u16) *PntList;
PntList++;
newYPos = (u16) *PntList;
PntList++;
if ( ( newXPos << 4 ) > m_base.vx )
{
m_pointRight = true;
}
else
{
m_pointRight = false;
}
// get slave trigger position
newXPos = (u16) *PntList;
PntList++;
newYPos = (u16) *PntList;
PntList++;
m_triggerPos.vx = newXPos;
m_triggerPos.vy = newYPos;
}
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
void CNpcTrapdoorPlatform::processMovement( int _frames )
{
s16 newAngle;
newAngle = getCollisionAngle();
if ( m_pointRight )
{
if ( m_triggered )
{
newAngle -= 32 * _frames;
if ( newAngle < 0 )
{
newAngle = 0;
}
setCollisionAngle( newAngle );
m_triggered = false;
}
else
{
newAngle += 32 * _frames;
if ( newAngle > 1024 )
{
newAngle = 1024;
}
setCollisionAngle( newAngle );
}
}
else
{
if ( m_triggered )
{
newAngle += 32 * _frames;
if ( newAngle > 0 )
{
newAngle = 0;
}
setCollisionAngle( newAngle );
m_triggered = false;
}
else
{
newAngle -= 32 * _frames;
if ( newAngle < -1024 )
{
newAngle = -1024;
}
setCollisionAngle( newAngle );
}
}
}
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
void CNpcTrapdoorPlatform::render()
{
if ( m_isActive )
{
CPlatformThing::render();
if (canRender())
{
DVECTOR &renderPos=getRenderPos();
SVECTOR rotation;
rotation.vx = 0;
if ( m_reversed )
{
rotation.vy = 0;
rotation.vz = getCollisionAngle() & 4095;
}
else
{
rotation.vy = 0;
rotation.vz = getCollisionAngle() & 4095;
}
VECTOR scale;
scale.vx = ONE;
scale.vy = ONE;
scale.vz = ONE;
m_modelGfx->Render(renderPos,&rotation,&scale);
}
}
}

View File

@ -0,0 +1,37 @@
/*=========================================================================
ptrpdoor.h
Author: CRB
Created:
Project: Spongebob
Purpose:
Copyright (c) 2001 Climax Development Ltd
===========================================================================*/
#ifndef __PLATFORM_PTRPDOOR_H__
#define __PLATFORM_PTRPDOOR_H__
#ifndef __PLATFORM_PLATFORM_H__
#include "platform\platform.h"
#endif
class CNpcTrapdoorPlatform : public CNpcPlatform
{
public:
virtual void postInit();
DVECTOR const &getTriggerPos() {return( m_triggerPos );}
void setTriggered() {m_triggered = true;}
virtual void render();
protected:
virtual void setWaypoints( sThingPlatform *ThisPlatform );
virtual void processMovement( int _frames );
DVECTOR m_triggerPos;
u8 m_triggered;
u8 m_pointRight;
};
#endif