From a0b66fcd158ae77354df619e475c776bdc3cd629 Mon Sep 17 00:00:00 2001 From: Charles Date: Tue, 24 Apr 2001 14:00:16 +0000 Subject: [PATCH] --- source/hazard/hpendulm.cpp | 58 ++++++++++++++++++++++++++++++++++++++ source/hazard/hpendulm.h | 29 +++++++++++++++++++ 2 files changed, 87 insertions(+) create mode 100644 source/hazard/hpendulm.cpp create mode 100644 source/hazard/hpendulm.h diff --git a/source/hazard/hpendulm.cpp b/source/hazard/hpendulm.cpp new file mode 100644 index 000000000..ce81a6f28 --- /dev/null +++ b/source/hazard/hpendulm.cpp @@ -0,0 +1,58 @@ +/*========================================================================= + + hpendulm.cpp + + Author: CRB + Created: + Project: Spongebob + Purpose: + + Copyright (c) 2001 Climax Development Ltd + +===========================================================================*/ + +#ifndef __HAZARD_HPENDULM_H__ +#include "hazard\hpendulm.h" +#endif + +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + +void CNpcPendulumHazard::init() +{ + CNpcHazard::init(); + + m_extendDir = EXTEND_LEFT; + m_extension = 0; + m_heading = 1024; +} + +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + +void CNpcPendulumHazard::processMovement( int _frames ) +{ + if ( m_extendDir == EXTEND_LEFT ) + { + if ( m_extension > 512 ) + { + m_extendDir = EXTEND_RIGHT; + } + else + { + m_extension += _frames << 3; + } + } + else + { + if ( m_extension < -512 ) + { + m_extendDir = EXTEND_LEFT; + } + else + { + m_extension -= _frames << 3; + } + } + + Pos.vx = m_base.vx + ( ( 100 * rcos( m_heading + m_extension ) ) >> 12 ); + Pos.vy = m_base.vy + ( ( 100 * rsin( m_heading + m_extension ) ) >> 12 ); +} \ No newline at end of file diff --git a/source/hazard/hpendulm.h b/source/hazard/hpendulm.h new file mode 100644 index 000000000..fbc69efe0 --- /dev/null +++ b/source/hazard/hpendulm.h @@ -0,0 +1,29 @@ +/*========================================================================= + + hpendulm.h + + Author: CRB + Created: + Project: Spongebob + Purpose: + + Copyright (c) 2001 Climax Development Ltd + +===========================================================================*/ + +#ifndef __HAZARD_HPENDULM_H__ +#define __HAZARD_HPENDULM_H__ + +#ifndef __HAZARD_HAZARD_H__ +#include "hazard\hazard.h" +#endif + +class CNpcPendulumHazard : public CNpcHazard +{ +public: + void init(); +protected: + void processMovement( int _frames ); +}; + +#endif \ No newline at end of file