@ -285,7 +285,7 @@ void Crawler::HandleUserInput(float fElapsedTime){
}
}
if ( player - > GetState ( ) ! = State : : NORMAL ) {
if ( player - > GetState ( ) ! = State : : NORMAL & & player - > GetState ( ) ! = State : : PREP_CAST ) {
setIdleAnimation = false ;
}
@ -313,8 +313,9 @@ void Crawler::HandleUserInput(float fElapsedTime){
void Crawler : : UpdateCamera ( float fElapsedTime ) {
lastWorldShakeAdjust = std : : max ( 0.f , lastWorldShakeAdjust - fElapsedTime ) ;
if ( worldShakeTime - fElapsedTime > 0 ) {
worldShakeVel = { 1000 , - 1000 } ;
if ( lastWorldShakeAdjust = = 0 ) {
lastWorldShakeAdjust = 0.02 ;
lastWorldShakeAdjust = 0.04 ;
worldShakeVel . x * = - 1 ;
worldShakeVel . y * = - 1 ;
}
@ -375,8 +376,8 @@ void Crawler::UpdateBullets(float fElapsedTime){
if ( ! b - > deactivated ) {
if ( b - > friendly ) {
for ( Monster & m : MONSTER_LIST ) {
if ( b - > OnUpperLevel ( ) = = m . OnUpperLevel ( ) & & 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 ( 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 , b - > OnUpperLevel ( ) ) ) {
if ( ! b - > hitsMultiple ) {
if ( b - > MonsterHit ( m ) ) {
it = BULLET_LIST . erase ( it ) ;
@ -391,8 +392,8 @@ void Crawler::UpdateBullets(float fElapsedTime){
}
}
} else {
if ( b - > OnUpperLevel ( ) = = player - > OnUpperLevel ( ) & & geom2d : : overlaps ( geom2d : : circle ( player - > GetPos ( ) , 12 * player - > GetSizeMult ( ) / 2 ) , geom2d : : circle ( b - > pos , b - > radius ) ) ) {
if ( player - > Hurt ( b - > damage ) ) {
if ( geom2d : : overlaps ( geom2d : : circle ( player - > GetPos ( ) , 12 * player - > GetSizeMult ( ) / 2 ) , geom2d : : circle ( b - > pos , b - > radius ) ) ) {
if ( player - > Hurt ( b - > damage , b - > OnUpperLevel ( ) ) ) {
if ( b - > PlayerHit ( GetPlayer ( ) ) ) {
it = BULLET_LIST . erase ( it ) ;
if ( it = = BULLET_LIST . end ( ) ) {
@ -427,8 +428,8 @@ void Crawler::UpdateBullets(float fElapsedTime){
}
void Crawler : : HurtEnemies ( vf2d pos , float radius , int damage , bool upperLevel ) {
for ( Monster & m : MONSTER_LIST ) {
if ( m . OnUpperLevel ( ) = = upperLevel & & geom2d : : overlaps ( geom2d : : circle ( pos , radius ) , geom2d : : circle ( m . GetPos ( ) , 12 * m . GetSizeMult ( ) ) ) ) {
m . Hurt ( damage ) ;
if ( geom2d : : overlaps ( geom2d : : circle ( pos , radius ) , geom2d : : circle ( m . GetPos ( ) , 12 * m . GetSizeMult ( ) ) ) ) {
m . Hurt ( damage , upperLevel ) ;
}
}
}
@ -575,11 +576,25 @@ void Crawler::RenderWorld(float fElapsedTime){
for ( Bullet * b : bulletsLower ) {
b - > Draw ( ) ;
}
auto RenderPrecastTargetingIndicator = [ & ] ( ) {
if ( player - > GetState ( ) = = State : : PREP_CAST ) {
float precastSize = GetPlayer ( ) - > castPrepAbility - > precastInfo . size ;
vf2d scale = vf2d { precastSize , precastSize } / 3.f ;
float precastRange = GetPlayer ( ) - > castPrepAbility - > precastInfo . range ;
vf2d scale = vf2d { precastSize , precastSize } * 2 / 3.f ;
vf2d centerPoint = GetWorldMousePos ( ) - vf2d { game - > GFX_Circle . Sprite ( ) - > width * scale . x / 2 , game - > GFX_Circle . Sprite ( ) - > height * scale . y / 2 } ;
float distance = sqrt ( pow ( player - > GetX ( ) - GetWorldMousePos ( ) . x , 2 ) + pow ( player - > GetY ( ) - GetWorldMousePos ( ) . y , 2 ) ) ;
if ( distance > precastRange ) { //Clamp the distance.
vf2d pointToCursor = { GetWorldMousePos ( ) . x - player - > GetX ( ) , GetWorldMousePos ( ) . y - player - > GetY ( ) } ;
pointToCursor = pointToCursor . norm ( ) * precastRange ;
vf2d centerPoint = player - > GetPos ( ) + pointToCursor - vf2d { game - > GFX_Circle . Sprite ( ) - > width * scale . x / 2 , game - > GFX_Circle . Sprite ( ) - > height * scale . y / 2 } ;
view . DrawDecal ( centerPoint , GFX_Circle . Decal ( ) , scale , { 255 , 0 , 0 , 96 } ) ;
} else {
view . DrawDecal ( centerPoint , GFX_Circle . Decal ( ) , scale , { 255 , 0 , 0 , 96 } ) ;
}
}
} ;
if ( ! player - > OnUpperLevel ( ) ) {
RenderPrecastTargetingIndicator ( ) ;
}
# pragma region Foreground Rendering
for ( TileGroup & group : foregroundTileGroups ) {
@ -642,6 +657,9 @@ void Crawler::RenderWorld(float fElapsedTime){
for ( Bullet * b : bulletsUpper ) {
b - > Draw ( ) ;
}
if ( player - > OnUpperLevel ( ) ) {
RenderPrecastTargetingIndicator ( ) ;
}
# pragma region Upper Foreground Rendering
for ( TileGroup & group : upperForegroundTileGroups ) {
if ( geom2d : : overlaps ( group . GetFadeRange ( ) , player - > pos ) ) {