From 0b2e74caf78020fc0099f54754302da9436d99dd Mon Sep 17 00:00:00 2001 From: Charles Date: Tue, 24 Apr 2001 21:03:46 +0000 Subject: [PATCH] --- source/platform/pbranch.cpp | 103 ++++++++++++++++++++++++++++++++++++ source/platform/pbranch.h | 36 +++++++++++++ 2 files changed, 139 insertions(+) create mode 100644 source/platform/pbranch.cpp create mode 100644 source/platform/pbranch.h diff --git a/source/platform/pbranch.cpp b/source/platform/pbranch.cpp new file mode 100644 index 000000000..e2b8e29d4 --- /dev/null +++ b/source/platform/pbranch.cpp @@ -0,0 +1,103 @@ +/*========================================================================= + + pbranch.cpp + + Author: CRB + Created: + Project: Spongebob + Purpose: + + Copyright (c) 2001 Climax Development Ltd + +===========================================================================*/ + +#ifndef __PLATFORM_PBRANCH_H__ +#include "platform\pbranch.h" +#endif + +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + +void CNpcBranchPlatform::postInit() +{ + m_state = NPC_BRANCH_STOP; +} + +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + +void CNpcBranchPlatform::processMovement( int _frames ) +{ + s16 tilt; + s16 maxTilt = 3 * _frames; + + switch( m_state ) + { + case NPC_BRANCH_STOP: + { + if ( m_contact ) + { + m_state = NPC_BRANCH_DIP; + } + else + { + if ( getCollisionAngle() ) + { + // go to zero bend + + tilt = -getCollisionAngle(); + + if ( tilt > maxTilt ) + { + tilt = maxTilt; + } + else if ( tilt < -maxTilt ) + { + tilt = -maxTilt; + } + + setCollisionAngle( getCollisionAngle() + tilt ); + } + } + + break; + } + + case NPC_BRANCH_DIP: + { + if ( m_contact ) + { + // bend + + tilt = 3 * _frames; + + s16 newAngle = getCollisionAngle() + tilt; + + if ( newAngle > 256 ) + { + // if bent beyond certain limit, spring + + m_state = NPC_BRANCH_SPRING; + } + + setCollisionAngle( newAngle ); + } + else + { + m_state = NPC_BRANCH_STOP; + } + + break; + } + + case NPC_BRANCH_SPRING: + { + if ( m_contact ) + { + // spring off player + } + + m_state = NPC_BRANCH_STOP; + + break; + } + } +} diff --git a/source/platform/pbranch.h b/source/platform/pbranch.h new file mode 100644 index 000000000..39467adc3 --- /dev/null +++ b/source/platform/pbranch.h @@ -0,0 +1,36 @@ +/*========================================================================= + + pbranch.h + + Author: CRB + Created: + Project: Spongebob + Purpose: + + Copyright (c) 2001 Climax Development Ltd + +===========================================================================*/ + +#ifndef __PLATFORM_PBRANCH_H__ +#define __PLATFORM_PBRANCH_H__ + +#ifndef __PLATFORM_PLATFORM_H__ +#include "platform\platform.h" +#endif + +class CNpcBranchPlatform : public CNpcPlatform +{ +public: + virtual void postInit(); +protected: + virtual void processMovement( int _frames ); + + enum NPC_BRANCH_STATE + { + NPC_BRANCH_STOP = 0, + NPC_BRANCH_DIP = 1, + NPC_BRANCH_SPRING, + }; +}; + +#endif \ No newline at end of file