SBSPSS/source/platform/prbridge.cpp

120 lines
2.7 KiB
C++
Raw Normal View History

2001-05-23 18:01:00 +02:00
/*=========================================================================
prbridge.cpp
Author: CRB
Created:
Project: Spongebob
Purpose:
Copyright (c) 2001 Climax Development Ltd
===========================================================================*/
#ifndef __PLATFORM_PRBRIDGE_H__
#include "platform\prbridge.h"
#endif
2001-05-29 22:31:02 +02:00
#include "triggers\trigger.h"
2001-05-23 18:01:00 +02:00
#ifndef __TRIGGERS_TPLATFRM_H__
#include "triggers\tplatfrm.h"
#endif
#ifndef __UTILS_HEADER__
#include "utils\utils.h"
#endif
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
void CNpcRisingBridgePlatform::postInit()
{
CNpcPlatform::postInit();
m_triggered = false;
}
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
void CNpcRisingBridgePlatform::trigger()
{
m_triggered = true;
}
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
void CNpcRisingBridgePlatform::setWaypoints( sThingPlatform *ThisPlatform )
{
ASSERT( ThisPlatform->PointCount == 3 );
u16 *PntList=(u16*)MakePtr(ThisPlatform,sizeof(sThingPlatform));
u16 newXPos, newYPos;
// get master platform init pos
newXPos = (u16) *PntList;
PntList++;
newYPos = (u16) *PntList;
PntList++;
DVECTOR startPos;
2001-05-31 18:24:48 +02:00
startPos.vx = ( newXPos << 4 ) + 8;
startPos.vy = ( newYPos << 4 ) + 16;
2001-05-23 18:01:00 +02:00
init( startPos );
m_extension = 0;
// get master platform max vertical extension
newXPos = (u16) *PntList;
PntList++;
newYPos = (u16) *PntList;
PntList++;
2001-05-31 18:24:48 +02:00
m_maxExtension = abs( ( ( newYPos << 4 ) + 16 ) - startPos.vy ) << 8;
2001-05-23 18:01:00 +02:00
// get slave trigger position
newXPos = (u16) *PntList;
PntList++;
newYPos = (u16) *PntList;
PntList++;
2001-05-30 18:52:52 +02:00
CPlatformTrigger *trigger;
2001-05-23 18:01:00 +02:00
2001-05-30 18:52:52 +02:00
// trigger = new ("PlatformTrigger") CPlatformTrigger();
trigger=(CPlatformTrigger*)CTrigger::Create(CTrigger::TRIGGER_PLATFORM);
2001-05-31 18:24:48 +02:00
trigger->setPositionAndSize( ( newXPos << 4 ) + 8, ( newYPos << 4 ) + 16, 100, 0 );
2001-05-23 18:01:00 +02:00
//trigger->setTargetBox(TriggerList->TargetPos.X<<4,TriggerList->TargetPos.Y<<4,TriggerList->TargetSize.X<<4,TriggerList->TargetSize.Y<<4);
trigger->setPlatform( this );
}
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
void CNpcRisingBridgePlatform::processMovement( int _frames )
{
if ( m_triggered )
{
m_triggered = false;
2001-05-29 20:40:38 +02:00
m_extension += ( m_dataPtr->speed * _frames ) << 8;
2001-05-23 18:01:00 +02:00
if ( m_extension > m_maxExtension )
{
m_extension = m_maxExtension;
}
}
else
{
m_extension -= 64 * _frames;
if ( m_extension < 0 )
{
m_extension = 0;
}
}
Pos.vy = m_base.vy - ( m_extension >> 8 );
}