This commit is contained in:
Charles 2001-02-12 20:03:44 +00:00
parent 90e7b63d9e
commit 48896226dc
3 changed files with 65 additions and 3 deletions

View File

@ -15,15 +15,75 @@
#include "enemy\npc.h"
#endif
#ifndef __GAME_GAME_H__
#include "game\game.h"
#endif
void CNpc::processGaryMovement( int _frames )
{
s8 multiplier = -1 + ( 2 * m_extension );
s32 maxHeight = 10;
s32 fallSpeed = 5;
// check vertical collision
if ( isCollisionWithGround() )
{
Pos.vx += _frames;
// check horizontal collision
if ( m_layerCollision->Get( ( Pos.vx + ( multiplier * _frames ) ) >> 4, ( Pos.vy - maxHeight ) >> 4 ) )
{
// reverse direction
m_extension = !m_extension;
}
else
{
s32 distY;
s32 lastPointY = 0;
for ( distY = 0 ; distY <= maxHeight ; distY++ )
{
if ( !m_layerCollision->Get( Pos.vx >> 4, ( Pos.vy - distY ) >> 4 ) )
{
break;
}
else
{
lastPointY--;
}
}
Pos.vy += lastPointY;
Pos.vx += multiplier * _frames;
}
}
else
{
Pos.vy += _frames;
if ( m_layerCollision->Get( Pos.vx >> 4, ( Pos.vy + ( fallSpeed * _frames ) ) >> 4 ) )
{
s32 distY;
s32 lastPointY = 0;
for ( distY = 1 ; distY <= _frames ; distY++ )
{
if ( m_layerCollision->Get( Pos.vx >> 4, ( Pos.vy + distY ) >> 4 ) )
{
break;
}
else
{
lastPointY++;
}
}
Pos.vy += lastPointY;
}
else
{
Pos.vy += fallSpeed * _frames;
}
}
}

View File

@ -102,5 +102,5 @@ void CNpc::processGenericGetUserDist( int _frames, s32 *distX, s32 *distY )
bool CNpc::isCollisionWithGround()
{
ASSERT(m_layerCollision);
return m_layerCollision->Get(Pos.vx>>4,Pos.vy>>4);
return m_layerCollision->Get( Pos.vx >> 4, ( Pos.vy + 1 ) >>4 );
}

View File

@ -62,6 +62,8 @@ void CNpc::init()
m_velocity = 0;
m_extension = 0;
m_extension = EXTEND_RIGHT;
Pos.vx = 100;
Pos.vy = 100;