From 4820e8a86dbe48f65e64fbd60fa8e554a56b1f74 Mon Sep 17 00:00:00 2001 From: Charles Date: Thu, 24 May 2001 14:39:30 +0000 Subject: [PATCH] --- source/hazard/hrckshrd.cpp | 109 +++++++++++++++++++++++++++++++++++++ source/hazard/hrckshrd.h | 39 +++++++++++++ 2 files changed, 148 insertions(+) create mode 100644 source/hazard/hrckshrd.cpp create mode 100644 source/hazard/hrckshrd.h diff --git a/source/hazard/hrckshrd.cpp b/source/hazard/hrckshrd.cpp new file mode 100644 index 000000000..bb080b78a --- /dev/null +++ b/source/hazard/hrckshrd.cpp @@ -0,0 +1,109 @@ +/*========================================================================= + + hrckshrd.cpp + + Author: CRB + Created: + Project: Spongebob + Purpose: + + Copyright (c) 2001 Climax Development Ltd + +===========================================================================*/ + +#ifndef __HAZARD_HRCKSHRD_H__ +#include "hazard\hrckshrd.h" +#endif + +#ifndef __GAME_GAME_H__ +#include "game\game.h" +#endif + +#ifndef __UTILS_HEADER__ +#include "utils\utils.h" +#endif + + +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + +void CNpcRockShardHazard::init() +{ + CNpcHazard::init(); + + m_movementTimer = 2 * GameState::getOneSecondInFrames(); + + m_respawnRate = 4; +} + +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + +void CNpcRockShardHazard::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 = 6 * _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 = ( m_respawnRate - 1 ) * GameState::getOneSecondInFrames(); + } + else + { + // drop down + + Pos.vy += yMovement; + } + } +} + +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + +void CNpcRockShardHazard::processTimer( int _frames ) +{ + m_timer -= _frames; + + if ( m_timer < 0 ) + { + m_timerActive = false; + m_isActive = true; + Pos = m_base; + m_movementTimer = 2 * GameState::getOneSecondInFrames(); + } +} + +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + +const CRECT *CNpcRockShardHazard::getThinkBBox() +{ + CRECT objThinkBox = getCollisionArea(); + + sBBox &thinkBBox = CThingManager::getThinkBBox(); + objThinkBox.y2 = thinkBBox.YMin + 1; + + return &objThinkBox; +} diff --git a/source/hazard/hrckshrd.h b/source/hazard/hrckshrd.h new file mode 100644 index 000000000..4b397e699 --- /dev/null +++ b/source/hazard/hrckshrd.h @@ -0,0 +1,39 @@ +/*========================================================================= + + hrckshrd.h + + Author: CRB + Created: + Project: Spongebob + Purpose: + + Copyright (c) 2001 Climax Development Ltd + +===========================================================================*/ + +#ifndef __HAZARD_HRCKSHRD_H__ +#define __HAZARD_HRCKSHRD_H__ + +#ifndef __HAZARD_HAZARD_H__ +#include "hazard\hazard.h" +#endif + +class CNpcRockShardHazard : public CNpcHazard +{ +public: + void init(); + virtual CRECT const *getThinkBBox(); +// virtual void setWaypoints( sThingHazard *ThisHazard ); +protected: + void processMovement( int _frames ); + void processTimer( int _frames ); +// virtual void collidedWith(CThing *_thisThing); + + s32 m_movementTimer; +// u8 m_bounceFinish; +// s32 m_speed; +// u8 m_bounceDir; +// DVECTOR m_bouncePos; +}; + +#endif \ No newline at end of file