This commit is contained in:
parent
630b615a33
commit
a1a35c7b5d
94
source/hazard/hfalling.cpp
Normal file
94
source/hazard/hfalling.cpp
Normal file
@ -0,0 +1,94 @@
|
||||
/*=========================================================================
|
||||
|
||||
hfalling.cpp
|
||||
|
||||
Author: CRB
|
||||
Created:
|
||||
Project: Spongebob
|
||||
Purpose:
|
||||
|
||||
Copyright (c) 2001 Climax Development Ltd
|
||||
|
||||
===========================================================================*/
|
||||
|
||||
#ifndef __HAZARD_HFALLING_H__
|
||||
#include "hazard\hfalling.h"
|
||||
#endif
|
||||
|
||||
#ifndef __GAME_GAME_H__
|
||||
#include "game\game.h"
|
||||
#endif
|
||||
|
||||
#ifndef __UTILS_HEADER__
|
||||
#include "utils\utils.h"
|
||||
#endif
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
void CNpcFallingHazard::init()
|
||||
{
|
||||
CNpcHazard::init();
|
||||
|
||||
m_movementTimer = 3 * GameState::getOneSecondInFrames();
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
void CNpcFallingHazard::processMovement( int _frames )
|
||||
{
|
||||
s8 groundHeight;
|
||||
s8 yMovement;
|
||||
|
||||
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
|
||||
{
|
||||
yMovement = 3 * _frames;
|
||||
|
||||
groundHeight = m_layerCollision->getHeightFromGround( Pos.vx, Pos.vy, yMovement + 16 );
|
||||
|
||||
if ( groundHeight < yMovement )
|
||||
{
|
||||
// colliding with ground
|
||||
|
||||
Pos.vy += groundHeight;
|
||||
|
||||
m_isActive = false;
|
||||
m_timerActive = true;
|
||||
m_timer = 3 * GameState::getOneSecondInFrames();
|
||||
}
|
||||
else
|
||||
{
|
||||
// drop down
|
||||
|
||||
Pos.vy += yMovement;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
void CNpcFallingHazard::processTimer( int _frames )
|
||||
{
|
||||
m_timer -= _frames;
|
||||
|
||||
if ( m_timer < 0 )
|
||||
{
|
||||
m_timerActive = false;
|
||||
m_isActive = true;
|
||||
Pos = m_base;
|
||||
m_movementTimer = 3 * GameState::getOneSecondInFrames();
|
||||
}
|
||||
}
|
32
source/hazard/hfalling.h
Normal file
32
source/hazard/hfalling.h
Normal file
@ -0,0 +1,32 @@
|
||||
/*=========================================================================
|
||||
|
||||
hfalling.h
|
||||
|
||||
Author: CRB
|
||||
Created:
|
||||
Project: Spongebob
|
||||
Purpose:
|
||||
|
||||
Copyright (c) 2001 Climax Development Ltd
|
||||
|
||||
===========================================================================*/
|
||||
|
||||
#ifndef __HAZARD_HFALLING_H__
|
||||
#define __HAZARD_HFALLING_H__
|
||||
|
||||
#ifndef __HAZARD_HAZARD_H__
|
||||
#include "hazard\hazard.h"
|
||||
#endif
|
||||
|
||||
class CNpcFallingHazard : public CNpcHazard
|
||||
{
|
||||
public:
|
||||
void init();
|
||||
protected:
|
||||
void processMovement( int _frames );
|
||||
void processTimer( int _frames );
|
||||
|
||||
s32 m_movementTimer;
|
||||
};
|
||||
|
||||
#endif
|
Loading…
Reference in New Issue
Block a user