diff --git a/source/platform/pfblock.cpp b/source/platform/pfblock.cpp new file mode 100644 index 000000000..3014c6eed --- /dev/null +++ b/source/platform/pfblock.cpp @@ -0,0 +1,102 @@ +/*========================================================================= + + pfblock.h + + Author: CRB + Created: + Project: Spongebob + Purpose: + + Copyright (c) 2001 Climax Development Ltd + +===========================================================================*/ + +#ifndef __PLATFORM_PFBLOCK_H__ +#include "platform\pfblock.h" +#endif + +#ifndef __GAME_GAME_H__ +#include "game\game.h" +#endif + +#ifndef __VID_HEADER_ +#include "system\vid.h" +#endif + +#ifndef __UTILS_HEADER__ +#include "utils\utils.h" +#endif + + +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + +void CNpcFallingBlockPlatform::postInit() +{ + CNpcPlatform::postInit(); + + m_isTriggered = false; + m_isFalling = false; +} + +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + +void CNpcFallingBlockPlatform::processMovement( int _frames ) +{ + if ( m_isTriggered ) + { + if ( m_timer > 0 ) + { + m_timer -= _frames; + + if ( m_timer <= 0 ) + { + Pos = m_base; + m_isFalling = true; + } + else + { + Pos.vx = m_base.vx + ( -3 + ( getRnd() % 7 ) ); + Pos.vy = m_base.vy + ( -3 + ( getRnd() % 7 ) ); + + if ( m_soundId == NOT_PLAYING ) + { + m_soundId = (int) CSoundMediator::playSfx( CSoundMediator::SFX_HAZARD__STALACTITE_RATTLE, true ); + } + } + } + else + { + DVECTOR offset = CLevel::getCameraPos(); + + s32 yPos = Pos.vy - offset.vy; + + if ( yPos > VidGetScrH() ) + { + setToShutdown(); + } + + s32 moveY = m_speed * _frames; + + Pos.vy += moveY; + } + } + else if ( m_contact ) + { + m_isTriggered = true; + m_timer = GameState::getOneSecondInFrames(); + } +} + +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + +int CNpcFallingBlockPlatform::checkCollisionAgainst(CThing *_thisThing, int _frames) +{ + if ( m_isFalling ) + { + return( false ); + } + else + { + return( CNpcPlatform::checkCollisionAgainst( _thisThing, _frames ) ); + } +} diff --git a/source/platform/pfblock.h b/source/platform/pfblock.h new file mode 100644 index 000000000..daf6d60ca --- /dev/null +++ b/source/platform/pfblock.h @@ -0,0 +1,35 @@ +/*========================================================================= + + pfblock.h + + Author: CRB + Created: + Project: Spongebob + Purpose: + + Copyright (c) 2001 Climax Development Ltd + +===========================================================================*/ + +#ifndef __PLATFORM_PFBLOCK_H__ +#define __PLATFORM_PFBLOCK_H__ + +#ifndef __PLATFORM_PLATFORM_H__ +#include "platform\platform.h" +#endif + +class CNpcFallingBlockPlatform : public CNpcPlatform +{ +public: + void postInit(); + CRECT const *getThinkBBox() {return( CThing::getThinkBBox() );} + int checkCollisionAgainst(CThing *_thisThing, int _frames); +protected: + void processMovement( int _frames ); + + u8 m_isTriggered; + u8 m_isFalling; + s32 m_timer; +}; + +#endif \ No newline at end of file