This commit is contained in:
parent
90e7b63d9e
commit
48896226dc
3 changed files with 65 additions and 3 deletions
|
@ -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;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -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 );
|
||||
}
|
||||
|
|
|
@ -62,6 +62,8 @@ void CNpc::init()
|
|||
m_velocity = 0;
|
||||
m_extension = 0;
|
||||
|
||||
m_extension = EXTEND_RIGHT;
|
||||
|
||||
Pos.vx = 100;
|
||||
Pos.vy = 100;
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue