This commit is contained in:
Charles 2001-04-12 14:55:55 +00:00
parent c08cf02803
commit 148b4416de
8 changed files with 62 additions and 21 deletions

View file

@ -133,6 +133,7 @@ void CNpcEnemy::processCloseAnemone1Attack( int _frames )
CProjectile *projectile; CProjectile *projectile;
projectile = new( "test projectile" ) CProjectile; projectile = new( "test projectile" ) CProjectile;
projectile->init( Pos, m_heading ); projectile->init( Pos, m_heading );
projectile->setLayerCollision( m_layerCollision );
m_controlFunc = NPC_CONTROL_MOVEMENT; m_controlFunc = NPC_CONTROL_MOVEMENT;
m_timerTimer = GameState::getOneSecondInFrames(); m_timerTimer = GameState::getOneSecondInFrames();
@ -200,6 +201,7 @@ void CNpcEnemy::processCloseAnemone2Attack( int _frames )
projectile = new( "anemone lev2 projectile" ) CProjectile; projectile = new( "anemone lev2 projectile" ) CProjectile;
projectile->init( spikePos, heading, CProjectile::PROJECTILE_FIXED, CProjectile::PROJECTILE_INFINITE_LIFE ); projectile->init( spikePos, heading, CProjectile::PROJECTILE_FIXED, CProjectile::PROJECTILE_INFINITE_LIFE );
projectile->setLayerCollision( m_layerCollision );
addChild( projectile ); addChild( projectile );
} }
@ -230,6 +232,7 @@ void CNpcEnemy::processCloseAnemone3Attack( int _frames )
CProjectile::PROJECTILE_GAS_CLOUD, CProjectile::PROJECTILE_GAS_CLOUD,
CProjectile::PROJECTILE_FINITE_LIFE, CProjectile::PROJECTILE_FINITE_LIFE,
lifetime * GameState::getOneSecondInFrames() ); lifetime * GameState::getOneSecondInFrames() );
projectile->setLayerCollision( m_layerCollision );
m_controlFunc = NPC_CONTROL_MOVEMENT; m_controlFunc = NPC_CONTROL_MOVEMENT;
m_timerFunc = NPC_TIMER_ATTACK_DONE; m_timerFunc = NPC_TIMER_ATTACK_DONE;

View file

@ -136,6 +136,7 @@ void CNpcEnemy::processStandardIronDogfishAttack( int _frames )
CProjectile *projectile; CProjectile *projectile;
projectile = new( "test projectile" ) CProjectile; projectile = new( "test projectile" ) CProjectile;
projectile->init( Pos, headingToPlayer ); projectile->init( Pos, headingToPlayer );
projectile->setLayerCollision( m_layerCollision );
m_state++; m_state++;

View file

@ -151,6 +151,7 @@ void CNpcEnemy::processCloseFlyingDutchmanAttack( int _frames )
CProjectile *projectile; CProjectile *projectile;
projectile = new( "test projectile" ) CProjectile; projectile = new( "test projectile" ) CProjectile;
projectile->init( Pos, heading ); projectile->init( Pos, heading );
projectile->setLayerCollision( m_layerCollision );
m_controlFunc = NPC_CONTROL_MOVEMENT; m_controlFunc = NPC_CONTROL_MOVEMENT;
m_movementTimer = GameState::getOneSecondInFrames() * 3; m_movementTimer = GameState::getOneSecondInFrames() * 3;

View file

@ -68,6 +68,7 @@ void CNpcEnemy::processCloseGhostPirateAttack( int _frames )
projectile = new( "test projectile" ) CProjectile; projectile = new( "test projectile" ) CProjectile;
projectile->init( Pos, heading ); projectile->init( Pos, heading );
projectile->setLayerCollision( m_layerCollision );
} }
} }
else if ( m_extendDir == EXTEND_DOWN ) else if ( m_extendDir == EXTEND_DOWN )

View file

@ -437,6 +437,7 @@ void CNpcEnemy::postInit()
CProjectile *projectile; CProjectile *projectile;
projectile = new ( "eyeball projectile" ) CProjectile; projectile = new ( "eyeball projectile" ) CProjectile;
projectile->init( Pos, m_fireHeading, CProjectile::PROJECTILE_FIXED, CProjectile::PROJECTILE_INFINITE_LIFE ); projectile->init( Pos, m_fireHeading, CProjectile::PROJECTILE_FIXED, CProjectile::PROJECTILE_INFINITE_LIFE );
projectile->setLayerCollision( m_layerCollision );
addChild( projectile ); addChild( projectile );
@ -461,6 +462,7 @@ void CNpcEnemy::postInit()
projectile = new( "anemone lev2 projectile" ) CProjectile; projectile = new( "anemone lev2 projectile" ) CProjectile;
projectile->init( spikePos, heading, CProjectile::PROJECTILE_FIXED, CProjectile::PROJECTILE_INFINITE_LIFE ); projectile->init( spikePos, heading, CProjectile::PROJECTILE_FIXED, CProjectile::PROJECTILE_INFINITE_LIFE );
projectile->setLayerCollision( m_layerCollision );
addChild( projectile ); addChild( projectile );
} }

View file

@ -59,6 +59,7 @@ void CNpcEnemy::processSubSharkMovement( int _frames )
CProjectile *projectile; CProjectile *projectile;
projectile = new( "test projectile" ) CProjectile; projectile = new( "test projectile" ) CProjectile;
projectile->init( Pos, 1024 ); projectile->init( Pos, 1024 );
projectile->setLayerCollision( m_layerCollision );
m_salvoCount--; m_salvoCount--;

View file

@ -229,6 +229,13 @@ void CProjectile::think(int _frames)
} }
case PROJECTILE_USER_SEEK: case PROJECTILE_USER_SEEK:
{
if ( m_layerCollision->Get( Pos.vx >> 4, Pos.vy >> 4 ) )
{
shutdown();
delete this;
}
else
{ {
switch( m_state ) switch( m_state )
{ {
@ -256,6 +263,7 @@ void CProjectile::think(int _frames)
break; break;
} }
} }
}
break; break;
} }
@ -282,9 +290,17 @@ void CProjectile::think(int _frames)
case PROJECTILE_DUMBFIRE: case PROJECTILE_DUMBFIRE:
default: default:
{
if ( m_layerCollision->Get( Pos.vx >> 4, Pos.vy >> 4 ) )
{
shutdown();
delete this;
}
else
{ {
Pos.vx += ( _frames * 3 * rcos( m_heading ) ) >> 12; Pos.vx += ( _frames * 3 * rcos( m_heading ) ) >> 12;
Pos.vy += ( _frames * 3 * rsin( m_heading ) ) >> 12; Pos.vy += ( _frames * 3 * rsin( m_heading ) ) >> 12;
}
break; break;
} }
@ -415,9 +431,17 @@ void CPlayerProjectile::think(int _frames)
{ {
case PLAYER_PROJECTILE_DUMBFIRE: case PLAYER_PROJECTILE_DUMBFIRE:
default: default:
{
if ( m_layerCollision->Get( Pos.vx >> 4, Pos.vy >> 4 ) )
{
shutdown();
delete this;
}
else
{ {
Pos.vx += ( _frames * 3 * rcos( m_heading ) ) >> 12; Pos.vx += ( _frames * 3 * rcos( m_heading ) ) >> 12;
Pos.vy += ( _frames * 3 * rsin( m_heading ) ) >> 12; Pos.vy += ( _frames * 3 * rsin( m_heading ) ) >> 12;
}
break; break;
} }

View file

@ -56,6 +56,10 @@ public:
void setState( PROJECTILE_STATE newState ); void setState( PROJECTILE_STATE newState );
void setLifeTime( PROJECTILE_LIFETIME_TYPE lifeType ); void setLifeTime( PROJECTILE_LIFETIME_TYPE lifeType );
void setPosition( DVECTOR newPos ); void setPosition( DVECTOR newPos );
void setLayerCollision( class CLayerCollision *_layer ) {m_layerCollision=_layer;}
private:
class CLayerCollision *m_layerCollision;
protected: protected:
DVECTOR getScreenOffset(); DVECTOR getScreenOffset();
@ -100,6 +104,10 @@ public:
PLAYER_PROJECTILE_MOVEMENT_TYPE getMovementType(); PLAYER_PROJECTILE_MOVEMENT_TYPE getMovementType();
void setLifeTime( PLAYER_PROJECTILE_LIFETIME_TYPE lifeType ); void setLifeTime( PLAYER_PROJECTILE_LIFETIME_TYPE lifeType );
void setPosition( DVECTOR newPos ); void setPosition( DVECTOR newPos );
void setLayerCollision( class CLayerCollision *_layer ) {m_layerCollision=_layer;}
private:
class CLayerCollision *m_layerCollision;
protected: protected:
DVECTOR getScreenOffset(); DVECTOR getScreenOffset();