This commit is contained in:
parent
7eb9067d9f
commit
3180b75a2c
2 changed files with 126 additions and 0 deletions
97
source/platform/plinear.cpp
Normal file
97
source/platform/plinear.cpp
Normal file
|
@ -0,0 +1,97 @@
|
||||||
|
/*=========================================================================
|
||||||
|
|
||||||
|
plinear.cpp
|
||||||
|
|
||||||
|
Author: CRB
|
||||||
|
Created:
|
||||||
|
Project: Spongebob
|
||||||
|
Purpose:
|
||||||
|
|
||||||
|
Copyright (c) 2001 Climax Development Ltd
|
||||||
|
|
||||||
|
===========================================================================*/
|
||||||
|
|
||||||
|
#ifndef __PLATFORM_PLINEAR_H__
|
||||||
|
#include "platform\plinear.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
void CNpcLinearPlatform::postInit()
|
||||||
|
{
|
||||||
|
m_npcPath.setPathType( CNpcPath::PONG_PATH );
|
||||||
|
}
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
void CNpcLinearPlatform::processMovement( int _frames )
|
||||||
|
{
|
||||||
|
s32 moveX = 0, moveY = 0;
|
||||||
|
s32 moveDist = 0;
|
||||||
|
|
||||||
|
bool pathComplete;
|
||||||
|
bool waypointChange;
|
||||||
|
|
||||||
|
s16 headingToTarget = m_npcPath.think( Pos, &pathComplete, &waypointChange );
|
||||||
|
|
||||||
|
if ( !pathComplete )
|
||||||
|
{
|
||||||
|
s16 decDir, incDir;
|
||||||
|
s16 maxTurnRate = m_data[m_type].turnSpeed;
|
||||||
|
|
||||||
|
decDir = m_heading - headingToTarget;
|
||||||
|
|
||||||
|
if ( decDir < 0 )
|
||||||
|
{
|
||||||
|
decDir += ONE;
|
||||||
|
}
|
||||||
|
|
||||||
|
incDir = headingToTarget - m_heading;
|
||||||
|
|
||||||
|
if ( incDir < 0 )
|
||||||
|
{
|
||||||
|
incDir += ONE;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( decDir < incDir )
|
||||||
|
{
|
||||||
|
*moveDist = -decDir;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
*moveDist = incDir;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( *moveDist < -maxTurnRate )
|
||||||
|
{
|
||||||
|
*moveDist = -maxTurnRate;
|
||||||
|
}
|
||||||
|
else if ( *moveDist > maxTurnRate )
|
||||||
|
{
|
||||||
|
*moveDist = maxTurnRate;
|
||||||
|
}
|
||||||
|
|
||||||
|
m_heading += *moveDist;
|
||||||
|
m_heading &= 4095;
|
||||||
|
|
||||||
|
s32 preShiftX = _frames * m_data[m_type].speed * rcos( m_heading );
|
||||||
|
s32 preShiftY = _frames * m_data[m_type].speed * rsin( m_heading );
|
||||||
|
|
||||||
|
*moveX = preShiftX >> 12;
|
||||||
|
if ( !(*moveX) && preShiftX )
|
||||||
|
{
|
||||||
|
*moveX = preShiftX / abs( preShiftX );
|
||||||
|
}
|
||||||
|
|
||||||
|
*moveY = preShiftY >> 12;
|
||||||
|
if ( !(*moveY) && preShiftY )
|
||||||
|
{
|
||||||
|
*moveY = preShiftY / abs( preShiftY );
|
||||||
|
}
|
||||||
|
|
||||||
|
//processGroundCollisionReverse( moveX, moveY );
|
||||||
|
}
|
||||||
|
|
||||||
|
Pos.vx += moveX;
|
||||||
|
Pos.vy += moveY;
|
||||||
|
}
|
29
source/platform/plinear.h
Normal file
29
source/platform/plinear.h
Normal file
|
@ -0,0 +1,29 @@
|
||||||
|
/*=========================================================================
|
||||||
|
|
||||||
|
plinear.h
|
||||||
|
|
||||||
|
Author: CRB
|
||||||
|
Created:
|
||||||
|
Project: Spongebob
|
||||||
|
Purpose:
|
||||||
|
|
||||||
|
Copyright (c) 2001 Climax Development Ltd
|
||||||
|
|
||||||
|
===========================================================================*/
|
||||||
|
|
||||||
|
#ifndef __PLATFORM_PLINEAR_H__
|
||||||
|
#define __PLATFORM_PLINEAR_H__
|
||||||
|
|
||||||
|
#ifndef __PLATFORM_PLATFORM_H__
|
||||||
|
#include "platform\platform.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
class CNpcLinearPlatform : public CNpcPlatform
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
virtual void postInit();
|
||||||
|
protected:
|
||||||
|
void processMovement( int _frames );
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif
|
Loading…
Add table
Reference in a new issue