This commit is contained in:
Charles 2001-05-04 16:20:10 +00:00
parent 6f7547caa2
commit 691742f26a
2 changed files with 36 additions and 8 deletions

View file

@ -23,14 +23,16 @@
void CNpcCartPlatform::postInit() void CNpcCartPlatform::postInit()
{ {
m_npcPath.setPathType( CNpcPath::PONG_PATH ); m_npcPath.setPathType( CNpcPath::SINGLE_USE_PATH );
m_carSpeed = m_data[m_type].speed << 8;
} }
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
void CNpcCartPlatform::processMovement( int _frames ) void CNpcCartPlatform::processMovement( int _frames )
{ {
s32 fallSpeed = 3; s32 fallSpeed = 2;
s8 yMovement = fallSpeed * _frames; s8 yMovement = fallSpeed * _frames;
s32 distX, distY, heading; s32 distX, distY, heading;
s32 groundHeight; s32 groundHeight;
@ -41,18 +43,23 @@ void CNpcCartPlatform::processMovement( int _frames )
m_npcPath.thinkFlat( Pos, &pathComplete, &distX, &distY, &heading ); m_npcPath.thinkFlat( Pos, &pathComplete, &distX, &distY, &heading );
moveX = m_data[m_type].speed * _frames; if ( !pathComplete )
if ( heading == 2048 )
{ {
moveX = -moveX; moveX = ( m_carSpeed >> 8 ) * _frames;
if ( heading == 2048 )
{
moveX = -moveX;
}
} }
// check for vertical movement // check for vertical movement
groundHeight = m_layerCollision->getHeightFromGround( Pos.vx + moveX, Pos.vy, yMovement + 16 ); s32 checkDist = yMovement + 50;
if ( groundHeight <= yMovement ) groundHeight = m_layerCollision->getHeightFromGround( Pos.vx + moveX, Pos.vy, checkDist );
if ( groundHeight < checkDist )
{ {
// groundHeight <= yMovement indicates either just above ground or on or below ground // groundHeight <= yMovement indicates either just above ground or on or below ground
@ -65,6 +72,25 @@ void CNpcCartPlatform::processMovement( int _frames )
moveY = yMovement; moveY = yMovement;
} }
if ( moveY < 0 )
{
m_carSpeed -= 20;
if ( m_carSpeed < ( 2 << 8 ) )
{
m_carSpeed = ( 2 << 8 );
}
}
else if ( moveY > 0 )
{
m_carSpeed += 20;
if ( m_carSpeed > ( 6 << 8 ) )
{
m_carSpeed = ( 6 << 8 );
}
}
Pos.vx += moveX; Pos.vx += moveX;
Pos.vy += moveY; Pos.vy += moveY;
} }

View file

@ -24,6 +24,8 @@ public:
virtual void postInit(); virtual void postInit();
protected: protected:
virtual void processMovement( int _frames ); virtual void processMovement( int _frames );
s32 m_carSpeed;
}; };
#endif #endif