diff --git a/source/platform/pleaf.cpp b/source/platform/pleaf.cpp new file mode 100644 index 000000000..8c2bec9e9 --- /dev/null +++ b/source/platform/pleaf.cpp @@ -0,0 +1,86 @@ +/*========================================================================= + + pleaf.cpp + + Author: CRB + Created: + Project: Spongebob + Purpose: + + Copyright (c) 2001 Climax Development Ltd + +===========================================================================*/ + +#ifndef __PLATFORM_PLEAF_H__ +#include "platform\pleaf.h" +#endif + +#ifndef __GAME_GAME_H__ +#include "game\game.h" +#endif + +#ifndef __UTILS_HEADER__ +#include "utils\utils.h" +#endif + +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + +void CNpcLeafPlatform::postInit() +{ + m_npcPath.setPathType( CNpcPath::SINGLE_USE_PATH ); + + m_isActive = false; + m_timer = 4 * GameState::getOneSecondInFrames(); + m_timerType = NPC_PLATFORM_TIMER_RESPAWN; + + m_isActivated = false; +} + +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + +void CNpcLeafPlatform::processMovement( int _frames ) +{ + if ( m_isActivated ) + { + s32 moveX, moveY; + s32 distX, distY, heading; + bool pathComplete; + + m_npcPath.thinkVertical( Pos, &pathComplete, &distX, &distY, &heading ); + + if ( pathComplete ) + { + m_isActive = false; + m_timer = getRnd() % ( 4 * GameState::getOneSecondInFrames() ); + m_timerType = NPC_PLATFORM_TIMER_RESPAWN; + } + else + { + moveX = 0; + moveY = m_data[m_type].speed * _frames; + + if ( heading == 3072 ) + { + moveY = -moveY; + } + + s32 groundHeight = m_layerCollision->getHeightFromGround( Pos.vx + moveX, Pos.vy + moveY, 16 ); + + if ( groundHeight < moveY ) + { + moveY = groundHeight; + moveX = 2 * _frames; + } + + Pos.vx += moveX; + Pos.vy += moveY; + } + } + else + { + if ( m_contact ) + { + m_isActivated = true; + } + } +} \ No newline at end of file diff --git a/source/platform/pleaf.h b/source/platform/pleaf.h new file mode 100644 index 000000000..6185c7314 --- /dev/null +++ b/source/platform/pleaf.h @@ -0,0 +1,31 @@ +/*========================================================================= + + pleaf.h + + Author: CRB + Created: + Project: Spongebob + Purpose: + + Copyright (c) 2001 Climax Development Ltd + +===========================================================================*/ + +#ifndef __PLATFORM_PLEAF_H__ +#define __PLATFORM_PLEAF_H__ + +#ifndef __PLATFORM_PLATFORM_H__ +#include "platform\platform.h" +#endif + +class CNpcLeafPlatform : public CNpcPlatform +{ +public: + virtual void postInit(); +protected: + virtual void processMovement( int _frames ); + + u8 m_isActivated; +}; + +#endif \ No newline at end of file