@ -60,6 +60,7 @@ bool Crawler::OnUserCreate(){
GFX_BulletCircleOutline . Load ( " assets/circle_outline.png " ) ;
GFX_BulletCircleOutline . Load ( " assets/circle_outline.png " ) ;
GFX_EnergyBolt . Load ( " assets/energy_bolt.png " ) ;
GFX_EnergyBolt . Load ( " assets/energy_bolt.png " ) ;
GFX_EnergyParticle . Load ( " assets/energy_particle.png " ) ;
GFX_EnergyParticle . Load ( " assets/energy_particle.png " ) ;
GFX_Splash_Effect . Load ( " assets/splash_effect.png " ) ;
//Animations
//Animations
InitializeAnimations ( ) ;
InitializeAnimations ( ) ;
@ -355,6 +356,12 @@ void Crawler::InitializeAnimations(){
energy_particle . AddFrame ( { & GFX_EnergyParticle , { { i * 3 , 0 } , { 3 , 3 } } } ) ;
energy_particle . AddFrame ( { & GFX_EnergyParticle , { { i * 3 , 0 } , { 3 , 3 } } } ) ;
}
}
ANIMATION_DATA [ AnimationState : : ENERGY_PARTICLE ] = energy_particle ;
ANIMATION_DATA [ AnimationState : : ENERGY_PARTICLE ] = energy_particle ;
Animate2D : : FrameSequence splash_animation ( 0.05 ) ;
for ( int i = 0 ; i < 5 ; i + + ) {
splash_animation . AddFrame ( { & GFX_Splash_Effect , { { i * 24 , 0 } , { 24 , 24 } } } ) ;
}
ANIMATION_DATA [ AnimationState : : SPLASH_EFFECT ] = splash_animation ;
}
}
bool Crawler : : LeftHeld ( ) {
bool Crawler : : LeftHeld ( ) {
@ -597,18 +604,21 @@ void Crawler::UpdateEffects(float fElapsedTime){
void Crawler : : UpdateBullets ( float fElapsedTime ) {
void Crawler : : UpdateBullets ( float fElapsedTime ) {
for ( auto it = BULLET_LIST . begin ( ) ; it ! = BULLET_LIST . end ( ) ; + + it ) {
for ( auto it = BULLET_LIST . begin ( ) ; it ! = BULLET_LIST . end ( ) ; + + it ) {
Bullet * b = ( * it ) . get ( ) ;
Bullet * b = ( * it ) . get ( ) ;
b - > UpdateFadeTime ( fElapsedTime ) ;
b - > Update ( fElapsedTime ) ;
b - > Update ( fElapsedTime ) ;
b - > pos + = b - > vel * fElapsedTime ;
b - > pos + = b - > vel * fElapsedTime ;
if ( geom2d : : overlaps ( geom2d : : circle ( player . GetPos ( ) , 12 * player . GetSizeMult ( ) / 2 ) , geom2d : : circle ( b - > pos , b - > radius ) ) ) {
if ( ! b - > deactivated & & geom2d : : overlaps ( geom2d : : circle ( player . GetPos ( ) , 12 * player . GetSizeMult ( ) / 2 ) , geom2d : : circle ( b - > pos , b - > radius ) ) ) {
if ( player . Hurt ( b - > damage ) ) {
if ( player . Hurt ( b - > damage ) ) {
if ( b - > PlayerHit ( player ) ) {
it = BULLET_LIST . erase ( it ) ;
it = BULLET_LIST . erase ( it ) ;
if ( it = = BULLET_LIST . end ( ) ) {
if ( it = = BULLET_LIST . end ( ) ) {
break ;
break ;
}
}
}
continue ;
continue ;
}
}
}
}
if ( b - > pos . x < view . GetWorldTL ( ) . x | | b - > pos . x > view . GetWorldBR ( ) . x | | b - > pos . y < view . GetWorldTL ( ) . y | | b - > pos . y > view . GetWorldBR ( ) . y ) {
if ( b - > pos . x + b - > radius < view . GetWorldTL ( ) . x | | b - > pos . x - b - > radius > view . GetWorldBR ( ) . x | | b - > pos . y + b - > radius < view . GetWorldTL ( ) . y | | b - > pos . y - b - > radius > view . GetWorldBR ( ) . y ) {
it = BULLET_LIST . erase ( it ) ;
it = BULLET_LIST . erase ( it ) ;
if ( it = = BULLET_LIST . end ( ) ) {
if ( it = = BULLET_LIST . end ( ) ) {
break ;
break ;
@ -627,22 +637,27 @@ void Crawler::UpdateBullets(float fElapsedTime){
}
}
for ( std : : vector < std : : unique_ptr < Bullet > > : : iterator it = PLAYER_BULLET_LIST . begin ( ) ; it ! = PLAYER_BULLET_LIST . end ( ) ; + + it ) {
for ( std : : vector < std : : unique_ptr < Bullet > > : : iterator it = PLAYER_BULLET_LIST . begin ( ) ; it ! = PLAYER_BULLET_LIST . end ( ) ; + + it ) {
std : : unique_ptr < Bullet > & b = * it ;
std : : unique_ptr < Bullet > & b = * it ;
b - > UpdateFadeTime ( fElapsedTime ) ;
b - > Update ( fElapsedTime ) ;
b - > Update ( fElapsedTime ) ;
b - > pos + = b - > vel * fElapsedTime ;
b - > pos + = b - > vel * fElapsedTime ;
if ( ! b - > deactivated ) {
for ( Monster & m : MONSTER_LIST ) {
for ( Monster & m : MONSTER_LIST ) {
if ( geom2d : : overlaps ( geom2d : : circle ( m . GetPos ( ) , 12 * m . GetSizeMult ( ) ) , geom2d : : circle ( b - > pos , b - > radius ) ) ) {
if ( geom2d : : overlaps ( geom2d : : circle ( m . GetPos ( ) , 12 * m . GetSizeMult ( ) ) , geom2d : : circle ( b - > pos , b - > radius ) ) ) {
if ( b - > hitList . find ( & m ) = = b - > hitList . end ( ) & & m . Hurt ( b - > damage ) ) {
if ( b - > hitList . find ( & m ) = = b - > hitList . end ( ) & & m . Hurt ( b - > damage ) ) {
if ( ! b - > hitsMultiple ) {
if ( ! b - > hitsMultiple ) {
if ( b - > MonsterHit ( m ) ) {
it = PLAYER_BULLET_LIST . erase ( it ) ;
it = PLAYER_BULLET_LIST . erase ( it ) ;
if ( it = = PLAYER_BULLET_LIST . end ( ) ) {
if ( it = = PLAYER_BULLET_LIST . end ( ) ) {
goto outsidePlayerBulletLoop ;
goto outsidePlayerBulletLoop ;
}
}
}
goto continuePlayerBulletLoop ;
goto continuePlayerBulletLoop ;
}
}
b - > hitList [ & m ] = true ;
b - > hitList [ & m ] = true ;
}
}
}
}
}
}
}
if ( b - > pos . x < view . GetWorldTL ( ) . x | | b - > pos . x > view . GetWorldBR ( ) . x | | b - > pos . y < view . GetWorldTL ( ) . y | | b - > pos . y > view . GetWorldBR ( ) . y ) {
if ( b - > pos . x < view . GetWorldTL ( ) . x | | b - > pos . x > view . GetWorldBR ( ) . x | | b - > pos . y < view . GetWorldTL ( ) . y | | b - > pos . y > view . GetWorldBR ( ) . y ) {
it = PLAYER_BULLET_LIST . erase ( it ) ;
it = PLAYER_BULLET_LIST . erase ( it ) ;
if ( it = = PLAYER_BULLET_LIST . end ( ) ) {
if ( it = = PLAYER_BULLET_LIST . end ( ) ) {