This commit is contained in:
parent
1f37c6678c
commit
2a7ebb2061
@ -25,14 +25,20 @@ void CNpc::processGaryMovement( int _frames )
|
|||||||
s8 multiplier = -1 + ( 2 * m_extension );
|
s8 multiplier = -1 + ( 2 * m_extension );
|
||||||
s32 maxHeight = 10;
|
s32 maxHeight = 10;
|
||||||
s32 fallSpeed = 5;
|
s32 fallSpeed = 5;
|
||||||
|
s8 yMovement = fallSpeed * _frames;
|
||||||
|
s8 groundHeight;
|
||||||
|
|
||||||
// check vertical collision
|
// check vertical collision
|
||||||
|
|
||||||
if ( isCollisionWithGround() )
|
groundHeight = m_layerCollision->getHeightFromGround( Pos.vx, Pos.vy, yMovement + 16 );
|
||||||
|
|
||||||
|
if ( groundHeight <= 0 )
|
||||||
{
|
{
|
||||||
|
// groundHeight <= 0 indicates either on ground or below ground
|
||||||
|
|
||||||
// check horizontal collision
|
// check horizontal collision
|
||||||
|
|
||||||
if ( m_layerCollision->Get( ( Pos.vx + ( multiplier * _frames ) ) >> 4, ( Pos.vy - maxHeight ) >> 4 ) )
|
if ( m_layerCollision->getHeightFromGround( Pos.vx + ( multiplier * _frames ), Pos.vy ) < -maxHeight )
|
||||||
{
|
{
|
||||||
// reverse direction
|
// reverse direction
|
||||||
|
|
||||||
@ -40,50 +46,37 @@ void CNpc::processGaryMovement( int _frames )
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
s32 distY;
|
// make sure we are on the ground, not below it
|
||||||
s32 lastPointY = 0;
|
|
||||||
|
|
||||||
for ( distY = 0 ; distY <= maxHeight ; distY++ )
|
Pos.vy += groundHeight;
|
||||||
{
|
|
||||||
if ( !m_layerCollision->Get( Pos.vx >> 4, ( Pos.vy - distY ) >> 4 ) )
|
|
||||||
{
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
lastPointY--;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Pos.vy += lastPointY;
|
|
||||||
|
|
||||||
Pos.vx += multiplier * _frames;
|
Pos.vx += multiplier * _frames;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if ( m_layerCollision->Get( Pos.vx >> 4, ( Pos.vy + ( fallSpeed * _frames ) ) >> 4 ) )
|
// above ground
|
||||||
|
|
||||||
|
if ( groundHeight < yMovement )
|
||||||
{
|
{
|
||||||
s32 distY;
|
// colliding with ground
|
||||||
s32 lastPointY = 0;
|
|
||||||
|
|
||||||
for ( distY = 1 ; distY <= _frames ; distY++ )
|
Pos.vy += groundHeight;
|
||||||
|
|
||||||
|
if ( m_layerCollision->getHeightFromGround( Pos.vx + ( multiplier * _frames ), Pos.vy ) < -maxHeight )
|
||||||
{
|
{
|
||||||
if ( m_layerCollision->Get( Pos.vx >> 4, ( Pos.vy + distY ) >> 4 ) )
|
// reverse direction
|
||||||
{
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
lastPointY++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Pos.vy += lastPointY;
|
m_extension = !m_extension;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Pos.vx += multiplier * _frames;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
Pos.vy += fallSpeed * _frames;
|
Pos.vy += yMovement;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -102,5 +102,5 @@ void CNpc::processGenericGetUserDist( int _frames, s32 *distX, s32 *distY )
|
|||||||
bool CNpc::isCollisionWithGround()
|
bool CNpc::isCollisionWithGround()
|
||||||
{
|
{
|
||||||
ASSERT(m_layerCollision);
|
ASSERT(m_layerCollision);
|
||||||
return m_layerCollision->Get( Pos.vx >> 4, ( Pos.vy + 1 ) >>4 );
|
return m_layerCollision->Get( Pos.vx >> 4, ( Pos.vy + 1 ) >> 4 ) ? 16:0;
|
||||||
}
|
}
|
||||||
|
@ -54,7 +54,7 @@ class CLayerCollision *CNpc::m_layerCollision;
|
|||||||
|
|
||||||
void CNpc::init()
|
void CNpc::init()
|
||||||
{
|
{
|
||||||
m_type = NPC_FALLING_ITEM;
|
m_type = NPC_GARY;
|
||||||
|
|
||||||
m_heading = m_fireHeading = 0;
|
m_heading = m_fireHeading = 0;
|
||||||
m_movementTimer = 0;
|
m_movementTimer = 0;
|
||||||
|
@ -26,6 +26,9 @@
|
|||||||
|
|
||||||
void CNpc::processCloseSkullStomperAttack( int _frames )
|
void CNpc::processCloseSkullStomperAttack( int _frames )
|
||||||
{
|
{
|
||||||
|
s8 groundHeight;
|
||||||
|
s8 yMovement;
|
||||||
|
|
||||||
if ( m_timerTimer > 0 )
|
if ( m_timerTimer > 0 )
|
||||||
{
|
{
|
||||||
// wait
|
// wait
|
||||||
@ -34,26 +37,15 @@ void CNpc::processCloseSkullStomperAttack( int _frames )
|
|||||||
{
|
{
|
||||||
if ( m_extendDir == EXTEND_DOWN )
|
if ( m_extendDir == EXTEND_DOWN )
|
||||||
{
|
{
|
||||||
if ( m_layerCollision->Get( Pos.vx >> 4, ( Pos.vy + ( m_data[m_type].speed * _frames ) ) >> 4 ) )
|
yMovement = m_data[m_type].speed * _frames;
|
||||||
|
|
||||||
|
groundHeight = m_layerCollision->getHeightFromGround( Pos.vx, Pos.vy, yMovement + 16 );
|
||||||
|
|
||||||
|
if ( groundHeight < yMovement )
|
||||||
{
|
{
|
||||||
// colliding with ground
|
// colliding with ground
|
||||||
|
|
||||||
s32 distY;
|
Pos.vy += groundHeight;
|
||||||
s32 lastPointY = 0;
|
|
||||||
|
|
||||||
for ( distY = 1 ; distY <= ( m_data[m_type].speed * _frames ) ; distY++ )
|
|
||||||
{
|
|
||||||
if ( m_layerCollision->Get( Pos.vx >> 4, ( Pos.vy + distY ) >> 4 ) )
|
|
||||||
{
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
lastPointY++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Pos.vy += lastPointY;
|
|
||||||
|
|
||||||
// pause and change direction
|
// pause and change direction
|
||||||
|
|
||||||
@ -64,7 +56,7 @@ void CNpc::processCloseSkullStomperAttack( int _frames )
|
|||||||
{
|
{
|
||||||
// drop down
|
// drop down
|
||||||
|
|
||||||
Pos.vy += m_data[m_type].speed * _frames;
|
Pos.vy += yMovement;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
Loading…
Reference in New Issue
Block a user