From 630b615a33d08d0f9cc02c3e9c32fcc40c43af03 Mon Sep 17 00:00:00 2001 From: Charles Date: Tue, 24 Apr 2001 13:24:26 +0000 Subject: [PATCH] --- source/hazard/hazard.cpp | 82 ++++++++++++++++++++++++++++++++++++++++ source/hazard/hazard.h | 49 ++++++++++++++++++++++++ 2 files changed, 131 insertions(+) create mode 100644 source/hazard/hazard.cpp create mode 100644 source/hazard/hazard.h diff --git a/source/hazard/hazard.cpp b/source/hazard/hazard.cpp new file mode 100644 index 000000000..f52345397 --- /dev/null +++ b/source/hazard/hazard.cpp @@ -0,0 +1,82 @@ +/*========================================================================= + + hazard.h + + Author: CRB + Created: + Project: Spongebob + Purpose: + + Copyright (c) 2001 Climax Development Ltd + +===========================================================================*/ + +#ifndef __HAZARD_HAZARD_H__ +#include "hazard\hazard.h" +#endif + +#ifndef __GAME_GAME_H__ +#include "game\game.h" +#endif + +#ifndef __VID_HEADER_ +#include "system\vid.h" +#endif + +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + +void CNpcHazard::init() +{ + CHazardThing::init(); + + m_actorGfx=CActorPool::GetActor( (FileEquate) ACTORS_CLAM_SBK ); + m_spriteBank=0; + + m_npcPath.initPath(); + + Pos.vx = 300; + Pos.vy = 300; +} + +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + +void CNpcHazard::shutdown() +{ + if (m_spriteBank) m_spriteBank->dump(); delete m_spriteBank; + // remove waypoints + + m_npcPath.removeAllWaypoints(); + + if (m_actorGfx) delete m_actorGfx; + + CHazardThing::shutdown(); +} + +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + +void CNpcHazard::think(int _frames) +{ + CHazardThing::think(_frames); +} + +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + +void CNpcHazard::render() +{ + CHazardThing::render(); + + // Render + DVECTOR renderPos; + DVECTOR offset = CLevel::getCameraPos(); + + renderPos.vx = Pos.vx - offset.vx; + renderPos.vy = Pos.vy - offset.vy; + + if ( renderPos.vx >= 0 && renderPos.vx <= VidGetScrW() ) + { + if ( renderPos.vy >= 0 && renderPos.vy <= VidGetScrH() ) + { + m_actorGfx->Render(renderPos,0,0,0); + } + } +} diff --git a/source/hazard/hazard.h b/source/hazard/hazard.h new file mode 100644 index 000000000..19b9b9d60 --- /dev/null +++ b/source/hazard/hazard.h @@ -0,0 +1,49 @@ +/*========================================================================= + + hazard.h + + Author: CRB + Created: + Project: Spongebob + Purpose: + + Copyright (c) 2001 Climax Development Ltd + +===========================================================================*/ + +#ifndef __HAZARD_HAZARD_H__ +#define __HAZARD_HAZARD_H__ + +#ifndef __THING_THING_H__ +#include "thing/thing.h" +#endif + +#ifndef __ENEMY_NPCPATH_H__ +#include "enemy\npcpath.h" +#endif + +#ifndef __GFX_SPRBANK_H__ +#include "gfx\sprbank.h" +#endif + +#ifndef __ACTOR_HEADER__ +#include "gfx\actor.h" +#endif + + +class CNpcHazard : public CHazardThing +{ +public: + void init(); + void shutdown(); + void think(int _frames); + void render(); + +protected: + CNpcPath m_npcPath; + CActorGfx *m_actorGfx; + SpriteBank *m_spriteBank; +}; + +#endif +