This commit is contained in:
parent
9b08f90fdd
commit
becb234bd7
4 changed files with 293 additions and 0 deletions
100
source/hazard/hrweight.cpp
Normal file
100
source/hazard/hrweight.cpp
Normal file
|
@ -0,0 +1,100 @@
|
|||
/*=========================================================================
|
||||
|
||||
hrweight.cpp
|
||||
|
||||
Author: CRB
|
||||
Created:
|
||||
Project: Spongebob
|
||||
Purpose:
|
||||
|
||||
Copyright (c) 2001 Climax Development Ltd
|
||||
|
||||
===========================================================================*/
|
||||
|
||||
#ifndef __HAZARD_HRWEIGHT_H__
|
||||
#include "hazard\hrweight.h"
|
||||
#endif
|
||||
|
||||
#ifndef __UTILS_HEADER__
|
||||
#include "utils\utils.h"
|
||||
#endif
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
void CNpcRisingWeightHazard::init()
|
||||
{
|
||||
CNpcHazard::init();
|
||||
|
||||
m_triggered = false;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
void CNpcRisingWeightHazard::setWaypoints( sThingHazard *ThisHazard )
|
||||
{
|
||||
ASSERT( ThisHazard->PointCount == 3 );
|
||||
|
||||
u16 *PntList=(u16*)MakePtr(ThisHazard,sizeof(sThingHazard));
|
||||
|
||||
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;
|
||||
|
||||
// get master hazard max vertical extension
|
||||
|
||||
newXPos = (u16) *PntList;
|
||||
PntList++;
|
||||
newYPos = (u16) *PntList;
|
||||
PntList++;
|
||||
|
||||
m_maxExtension = abs( ( newYPos << 4 ) - startPos.vy ) << 8;
|
||||
|
||||
// get slave trigger position
|
||||
|
||||
newXPos = (u16) *PntList;
|
||||
PntList++;
|
||||
newYPos = (u16) *PntList;
|
||||
PntList++;
|
||||
|
||||
m_wheelPos.vx = newXPos;
|
||||
m_wheelPos.vy = newYPos;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
void CNpcRisingWeightHazard::processMovement( int _frames )
|
||||
{
|
||||
if ( m_triggered )
|
||||
{
|
||||
m_triggered = false;
|
||||
m_extension += ( 3 * _frames ) << 8;
|
||||
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 );
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue