This commit is contained in:
Charles 2001-02-15 20:50:52 +00:00
parent 1f37c6678c
commit 2a7ebb2061
4 changed files with 37 additions and 52 deletions

View File

@ -25,14 +25,20 @@ void CNpc::processGaryMovement( int _frames )
s8 multiplier = -1 + ( 2 * m_extension );
s32 maxHeight = 10;
s32 fallSpeed = 5;
s8 yMovement = fallSpeed * _frames;
s8 groundHeight;
// 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
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
@ -40,50 +46,37 @@ void CNpc::processGaryMovement( int _frames )
}
else
{
s32 distY;
s32 lastPointY = 0;
// make sure we are on the ground, not below it
for ( distY = 0 ; distY <= maxHeight ; distY++ )
{
if ( !m_layerCollision->Get( Pos.vx >> 4, ( Pos.vy - distY ) >> 4 ) )
{
break;
}
else
{
lastPointY--;
}
}
Pos.vy += lastPointY;
Pos.vy += groundHeight;
Pos.vx += multiplier * _frames;
}
}
else
{
if ( m_layerCollision->Get( Pos.vx >> 4, ( Pos.vy + ( fallSpeed * _frames ) ) >> 4 ) )
{
s32 distY;
s32 lastPointY = 0;
// above ground
for ( distY = 1 ; distY <= _frames ; distY++ )
if ( groundHeight < yMovement )
{
if ( m_layerCollision->Get( Pos.vx >> 4, ( Pos.vy + distY ) >> 4 ) )
// colliding with ground
Pos.vy += groundHeight;
if ( m_layerCollision->getHeightFromGround( Pos.vx + ( multiplier * _frames ), Pos.vy ) < -maxHeight )
{
break;
// reverse direction
m_extension = !m_extension;
}
else
{
lastPointY++;
Pos.vx += multiplier * _frames;
}
}
Pos.vy += lastPointY;
}
else
{
Pos.vy += fallSpeed * _frames;
Pos.vy += yMovement;
}
}
}

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 + 1 ) >>4 );
return m_layerCollision->Get( Pos.vx >> 4, ( Pos.vy + 1 ) >> 4 ) ? 16:0;
}

View File

@ -54,7 +54,7 @@ class CLayerCollision *CNpc::m_layerCollision;
void CNpc::init()
{
m_type = NPC_FALLING_ITEM;
m_type = NPC_GARY;
m_heading = m_fireHeading = 0;
m_movementTimer = 0;

View File

@ -26,6 +26,9 @@
void CNpc::processCloseSkullStomperAttack( int _frames )
{
s8 groundHeight;
s8 yMovement;
if ( m_timerTimer > 0 )
{
// wait
@ -34,26 +37,15 @@ void CNpc::processCloseSkullStomperAttack( int _frames )
{
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
s32 distY;
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;
Pos.vy += groundHeight;
// pause and change direction
@ -64,7 +56,7 @@ void CNpc::processCloseSkullStomperAttack( int _frames )
{
// drop down
Pos.vy += m_data[m_type].speed * _frames;
Pos.vy += yMovement;
}
}
else