From 0ef5e735f78e85cb2bb6f59607dfed6a214522ee Mon Sep 17 00:00:00 2001 From: Charles Date: Thu, 3 May 2001 20:47:20 +0000 Subject: [PATCH] --- source/enemy/nanemone.cpp | 107 +++++++++++++++++++++++++++++++++++++ source/enemy/nanemone.h | 4 ++ source/projectl/projectl.h | 1 + 3 files changed, 112 insertions(+) diff --git a/source/enemy/nanemone.cpp b/source/enemy/nanemone.cpp index 3188d69e2..b2be2f70e 100644 --- a/source/enemy/nanemone.cpp +++ b/source/enemy/nanemone.cpp @@ -27,6 +27,10 @@ #include "game\game.h" #endif +#ifndef __VID_HEADER_ +#include "system\vid.h" +#endif + #ifndef __PLAYER_PLAYER_H__ #include "player\player.h" #endif @@ -39,17 +43,23 @@ #include #endif +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + void CNpcAnemoneEnemy::postInit() { CNpcEnemy::postInit(); m_drawRotation = m_heading + 1024; } +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + void CNpcAnemoneEnemy::processEnemyCollision( CThing *thisThing ) { // do nothing } +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + bool CNpcAnemoneEnemy::processSensor() { switch( m_sensorFunc ) @@ -73,6 +83,8 @@ bool CNpcAnemoneEnemy::processSensor() } } +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + void CNpcAnemone1Enemy::processClose( int _frames ) { s32 moveX, moveY; @@ -200,6 +212,8 @@ void CNpcAnemone1Enemy::processClose( int _frames ) } } +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + void CNpcAnemone2Enemy::postInit() { CProjectile *projectile; @@ -228,14 +242,21 @@ void CNpcAnemone2Enemy::postInit() } m_drawRotation = m_heading + 1024; + + m_scaleX = ONE; + m_scaleY = ONE; } +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + void CNpcAnemone2Enemy::shutdown() { deleteAllChild(); CNpcEnemy::shutdown(); } +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + void CNpcAnemone2Enemy::processClose( int _frames ) { int fireLoop; @@ -306,6 +327,92 @@ void CNpcAnemone2Enemy::processClose( int _frames ) } } +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + +void CNpcAnemone2Enemy::processMovementModifier( int _frames, s32 distX, s32 distY, s32 dist, s16 headingChange ) +{ + s32 maxTimer = GameState::getOneSecondInFrames() >> 1; + + m_movementTimer += _frames; + + if ( m_movementTimer > maxTimer ) + { + m_movementTimer -= maxTimer; + } + + s32 sineVal = ( m_movementTimer * ONE ) / maxTimer; + + m_scaleX = ONE + ( rsin( sineVal ) >> 2 ); + m_scaleY = ONE + ( rcos( sineVal ) >> 2 ); + + CProjectile *projectile; + projectile = (CProjectile *) Next; + + for ( int fireLoop = 0 ; fireLoop < 5 ; fireLoop++ ) + { + DVECTOR spikePos; + + s16 heading = m_heading - 1024 + ( fireLoop * 512 ); + heading &= 4095; + + spikePos = Pos; + + s16 multiplier, multiplier2; + + spikePos.vx += ( 10 * rcos( m_heading ) ) >> 12; + spikePos.vy += ( 10 * rsin( m_heading ) ) >> 12; + + multiplier = ( m_scaleX * 40 ) >> 12; + multiplier2 = ( m_scaleY * 40 ) >> 12; + + multiplier += multiplier2; + multiplier >>= 1; + + spikePos.vx += ( multiplier * rcos( heading ) ) >> 12; + spikePos.vy += ( multiplier * rsin( heading ) ) >> 12; + + if ( projectile ) + { + projectile->setPos( spikePos ); + projectile = (CProjectile *) projectile->getNext(); + } + } +} + +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + +void CNpcAnemone2Enemy::render() +{ + SprFrame = NULL; + + if ( m_isActive ) + { + CEnemyThing::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() ) + { + SprFrame = m_actorGfx->Render(renderPos,m_animNo,( m_frame >> 8 ),m_reversed); + m_actorGfx->RotateScale( SprFrame, renderPos, m_drawRotation, m_scaleX, m_scaleY ); + + sBBox boundingBox = m_actorGfx->GetBBox(); + setCollisionSize( ( boundingBox.XMax - boundingBox.XMin ), ( boundingBox.YMax - boundingBox.YMin ) ); + setCollisionCentreOffset( ( boundingBox.XMax + boundingBox.XMin ) >> 1, ( boundingBox.YMax + boundingBox.YMin ) >> 1 ); + } + } + } +} + +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + void CNpcAnemone3Enemy::processClose( int _frames ) { if ( m_animNo != ANIM_ANENOME_FIRE ) diff --git a/source/enemy/nanemone.h b/source/enemy/nanemone.h index 3f4fbf32d..1b91890ac 100644 --- a/source/enemy/nanemone.h +++ b/source/enemy/nanemone.h @@ -38,8 +38,12 @@ class CNpcAnemone2Enemy : public CNpcAnemoneEnemy public: virtual void postInit(); virtual void shutdown(); + virtual void render(); protected: virtual void processClose( int _frames ); + virtual void processMovementModifier( int _frames, s32 distX, s32 distY, s32 dist, s16 headingChange ); + + u16 m_scaleX, m_scaleY; }; class CNpcAnemone3Enemy : public CNpcAnemoneEnemy diff --git a/source/projectl/projectl.h b/source/projectl/projectl.h index a9181bf07..4651b0d81 100644 --- a/source/projectl/projectl.h +++ b/source/projectl/projectl.h @@ -51,6 +51,7 @@ public: void setToShutdown(); u8 isSetToShutdown() {return( m_isShuttingDown );} void think(int _frames); + void setPos( DVECTOR newPos ) {Pos = newPos;} virtual void render(); void processEvent( GAME_EVENT evt, CThing *sourceThing ); void setMovementType( PROJECTILE_MOVEMENT_TYPE moveType );