From e011ac910ad6defaf4a693372d7015867fcf13a5 Mon Sep 17 00:00:00 2001 From: Charles Date: Tue, 24 Apr 2001 14:13:32 +0000 Subject: [PATCH] --- source/hazard/hfirebal.cpp | 98 ++++++++++++++++++++++++++++++++++++++ source/hazard/hfirebal.h | 32 +++++++++++++ 2 files changed, 130 insertions(+) create mode 100644 source/hazard/hfirebal.cpp create mode 100644 source/hazard/hfirebal.h diff --git a/source/hazard/hfirebal.cpp b/source/hazard/hfirebal.cpp new file mode 100644 index 000000000..8d36d84a0 --- /dev/null +++ b/source/hazard/hfirebal.cpp @@ -0,0 +1,98 @@ +/*========================================================================= + + hfirebal.cpp + + Author: CRB + Created: + Project: Spongebob + Purpose: + + Copyright (c) 2001 Climax Development Ltd + +===========================================================================*/ + +#ifndef __HAZARD_HFIREBAL_H__ +#include "hazard\hfirebal.h" +#endif + +#ifndef __GAME_GAME_H__ +#include "game\game.h" +#endif + + +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + +void CNpcFireballHazard::init() +{ + CNpcHazard::init(); + + DVECTOR newPos; + + Pos.vx = 100; + Pos.vy = 100; + m_base = Pos; + + newPos.vx = 300; + newPos.vy = 100; + + m_npcPath.addWaypoint( newPos ); + m_npcPath.setPathType( CNpcPath::SINGLE_USE_PATH ); + + m_extension = 0; + m_velocity = 40; + m_timer = GameState::getOneSecondInFrames() * 3; +} + +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + +void CNpcFireballHazard::processMovement( int _frames ) +{ + s32 distX; + s32 distY; + s32 velocity; + s32 distSourceX; + s32 distSourceY; + + m_npcPath.getDistToNextWaypoint( Pos, &distX, &distY ); + m_npcPath.getDistToNextWaypoint( m_base, &distSourceX, &distSourceY ); + + if ( m_extension < 4096 ) + { + velocity = m_velocity * _frames; + + if ( 4096 - m_extension < velocity ) + { + velocity = 4096 - m_extension; + } + + m_extension += velocity; + } + else + { + // move complete + + Pos = m_base; + m_extension = 0; + m_isActive = false; + m_timerActive = true; + m_timer = 3 * GameState::getOneSecondInFrames(); + + return; + } + + Pos.vx = m_base.vx + ( ( distSourceX * m_extension ) >> 12 ); + Pos.vy = m_base.vy - ( 50 * rsin( m_extension >> 1 ) >> 12 ); +} + +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + +void CNpcFireballHazard::processTimer( int _frames ) +{ + m_timer -= _frames; + + if ( m_timer < 0 ) + { + m_timerActive = false; + m_isActive = true; + } +} diff --git a/source/hazard/hfirebal.h b/source/hazard/hfirebal.h new file mode 100644 index 000000000..0747fe227 --- /dev/null +++ b/source/hazard/hfirebal.h @@ -0,0 +1,32 @@ +/*========================================================================= + + hfirebal.h + + Author: CRB + Created: + Project: Spongebob + Purpose: + + Copyright (c) 2001 Climax Development Ltd + +===========================================================================*/ + +#ifndef __HAZARD_HFIREBAL_H__ +#define __HAZARD_HFIREBAL_H__ + +#ifndef __HAZARD_HAZARD_H__ +#include "hazard\hazard.h" +#endif + +class CNpcFireballHazard : public CNpcHazard +{ +public: + void init(); +protected: + void processMovement( int _frames ); + void processTimer( int _frames ); + + s32 m_velocity; +}; + +#endif \ No newline at end of file