diff --git a/source/enemy/nanemone.cpp b/source/enemy/nanemone.cpp new file mode 100644 index 000000000..8d43a919f --- /dev/null +++ b/source/enemy/nanemone.cpp @@ -0,0 +1,46 @@ +/*========================================================================= + + nanemone.cpp + + Author: CRB + Created: + Project: Spongebob + Purpose: + + Copyright (c) 2000 Climax Development Ltd + +===========================================================================*/ + +#ifndef __ENEMY_NPC_H__ +#include "enemy\npc.h" +#endif + +#ifndef __PROJECTL_PROJECTL_H__ +#include "projectl\projectl.h" +#endif + +#ifndef __GAME_GAME_H__ +#include "game\game.h" +#endif + + +void CNpc::processCloseAnemone2Attack( int _frames ) +{ + int fireLoop; + CProjectile *projectile; + s16 heading; + + for ( fireLoop = 0 ; fireLoop < 5 ; fireLoop++ ) + { + heading = m_baseHeading - 1024 + ( fireLoop * 512 ); + heading %= 4096; + + projectile = new( "test projectile" ) CProjectile; + projectile->init( Pos, heading ); + } + + m_controlFunc = NPC_CONTROL_MOVEMENT; + m_timerFunc = NPC_TIMER_ATTACK_DONE; + m_timerTimer = GameState::getOneSecondInFrames(); + m_sensorFunc = NPC_SENSOR_NONE; +} \ No newline at end of file diff --git a/source/projectl/projectl.cpp b/source/projectl/projectl.cpp new file mode 100644 index 000000000..e742686c4 --- /dev/null +++ b/source/projectl/projectl.cpp @@ -0,0 +1,107 @@ +/*========================================================================= + + projectl.cpp + + Author: CRB + Created: + Project: Spongebob + Purpose: + + Copyright (c) 2000 Climax Development Ltd + +===========================================================================*/ + +#ifndef __PROJECTL_PROJECTL_H__ +#include "projectl\projectl.h" +#endif + +#ifndef __GFX_SPRBANK_H__ +#include "gfx\sprbank.h" +#endif + +#ifndef __LEVEL_LEVEL_H__ +#include "level\level.h" +#endif + +#ifndef __FILE_EQUATES_H__ +#include +#endif + +#ifndef __SPR_UIGFX_H__ +#include +#endif + +#ifndef __VID_HEADER_ +#include "system\vid.h" +#endif + +#ifndef __GAME_GAME_H__ +#include "game\game.h" +#endif + + +/*****************************************************************************/ + +void CProjectile::init() +{ + m_spriteBank=new ("projectile sprites") SpriteBank(); + m_spriteBank->load(UI_UIGFX_SPR); + + m_heading = 0; + m_lifetime = GameState::getOneSecondInFrames() * 2; +} + +void CProjectile::init( DVECTOR initPos, s16 initHeading ) +{ + init(); + + m_heading = initHeading; + Pos = initPos; +} + +void CProjectile::shutdown() +{ + m_spriteBank->dump(); delete m_spriteBank; +} + +void CProjectile::think(int _frames) +{ + Pos.vx += ( _frames * 3 * rcos( m_heading ) ) >> 12; + Pos.vy += ( _frames * 3 * rsin( m_heading ) ) >> 12; + + m_lifetime -= _frames; + + if ( m_lifetime <= 0 ) + { + shutdown(); + delete this; + } +} + +void CProjectile::render() +{ + DVECTOR offset; + int x,y; + int scrnWidth = VidGetScrW(); + int scrnHeight = VidGetScrH(); + int spriteWidth = m_spriteBank->getFrameWidth(FRM_BARNACLEBOY); + int spriteHeight = m_spriteBank->getFrameHeight(FRM_BARNACLEBOY); + + offset = getScreenOffset(); + + x = Pos.vx - offset.vx + ( scrnWidth >> 1 ) - ( spriteWidth >> 1 ); + y = Pos.vy - offset.vy + ( scrnHeight >> 1 ) - ( spriteHeight >> 1 ); + + m_spriteBank->printFT4(FRM_BARNACLEBOY,x,y,0,0,0); +} + +DVECTOR CProjectile::getScreenOffset() +{ + return CLevel::getCameraPos(); +} + +void CProjectile::processEvent( GAME_EVENT evt, CThing *sourceThing ) +{ +} + +/*****************************************************************************/ diff --git a/source/projectl/projectl.h b/source/projectl/projectl.h new file mode 100644 index 000000000..35b80e5de --- /dev/null +++ b/source/projectl/projectl.h @@ -0,0 +1,42 @@ +/*========================================================================= + + projectl.h + + Author: CRB + Created: + Project: Spongebob + Purpose: + + Copyright (c) 2000 Climax Development Ltd + +===========================================================================*/ + +#ifndef __PROJECTL_PROJECTL_H__ +#define __PROJECTL_PROJECTL_H__ + +#include "Game/Thing.h" +#include "Gfx/Skel.h" + +/*****************************************************************************/ + +class CProjectile : public CThing +{ +public: + void init(); + void init( DVECTOR initPos, s16 initHeading ); + void shutdown(); + void think(int _frames); + virtual void render(); + void processEvent( GAME_EVENT evt, CThing *sourceThing ); + +protected: + DVECTOR getScreenOffset(); + + class SpriteBank *m_spriteBank; + s16 m_heading; + s32 m_lifetime; +}; + + +/*****************************************************************************/ +#endif