This commit is contained in:
Charles 2001-05-10 21:30:17 +00:00
parent 47d5bb7fc7
commit 58756ef755
11 changed files with 287 additions and 33 deletions

View file

@ -23,6 +23,11 @@
#include "utils\utils.h"
#endif
#ifndef __VID_HEADER_
#include "system\vid.h"
#endif
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
void CNpcFallingHazard::init()
@ -32,6 +37,7 @@ void CNpcFallingHazard::init()
m_movementTimer = 2 * GameState::getOneSecondInFrames();
m_respawnRate = 4;
m_bounceFinish = false;
}
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
@ -41,41 +47,73 @@ void CNpcFallingHazard::processMovement( int _frames )
s8 groundHeight;
s8 yMovement;
if ( m_movementTimer > 0 )
if ( m_bounceFinish )
{
m_movementTimer -= _frames;
if ( m_movementTimer <= 0 )
if ( m_bounceDir )
{
Pos = m_base;
Pos.vx += 2 * _frames;
}
else
{
Pos.vx = m_base.vx + ( -3 + ( getRnd() % 7 ) );
Pos.vy = m_base.vy + ( -3 + ( getRnd() % 7 ) );
Pos.vx -= 2 * _frames;
}
}
else
{
yMovement = 3 * _frames;
groundHeight = m_layerCollision->getHeightFromGround( Pos.vx, Pos.vy, yMovement + 16 );
Pos.vy += m_speed * _frames;
if ( groundHeight < yMovement )
if ( m_speed < 5 )
{
// colliding with ground
m_speed++;
}
Pos.vy += groundHeight;
DVECTOR offset = CLevel::getCameraPos();
s32 yPos = Pos.vy - offset.vy;
if ( yPos > VidGetScrH() || yPos < 0 )
{
m_isActive = false;
m_timerActive = true;
m_timer = ( m_respawnRate - 1 ) * GameState::getOneSecondInFrames();
}
}
else
{
if ( m_movementTimer > 0 )
{
m_movementTimer -= _frames;
if ( m_movementTimer <= 0 )
{
Pos = m_base;
}
else
{
Pos.vx = m_base.vx + ( -3 + ( getRnd() % 7 ) );
Pos.vy = m_base.vy + ( -3 + ( getRnd() % 7 ) );
}
}
else
{
// drop down
yMovement = 3 * _frames;
Pos.vy += yMovement;
groundHeight = m_layerCollision->getHeightFromGround( Pos.vx, Pos.vy, yMovement + 16 );
if ( groundHeight < yMovement )
{
// colliding with ground
Pos.vy += groundHeight;
m_bounceFinish = true;
m_speed = -5;
m_bounceDir = getRnd() % 2;
}
else
{
// drop down
Pos.vy += yMovement;
}
}
}
}
@ -92,5 +130,6 @@ void CNpcFallingHazard::processTimer( int _frames )
m_isActive = true;
Pos = m_base;
m_movementTimer = 2 * GameState::getOneSecondInFrames();
m_bounceFinish = false;
}
}