From 73d29a2ab566287c1e401fac87a6ee7b064fdf4d Mon Sep 17 00:00:00 2001 From: sigonasr2 Date: Fri, 21 Jul 2023 17:29:20 -0500 Subject: [PATCH] Added lingering field effect. --- Crawler/Animation.cpp | 6 ++++ Crawler/Animation.h | 1 + Crawler/Crawler.vcxproj | 1 + Crawler/Crawler.vcxproj.filters | 3 ++ Crawler/Effect.h | 8 +++++ Crawler/Meteor.cpp | 19 ++++++++--- Crawler/PulsatingFire.cpp | 57 +++++++++++++++++++++++++++++++++ Crawler/Version.h | 2 +- Crawler/Wizard.cpp | 2 +- 9 files changed, 92 insertions(+), 7 deletions(-) create mode 100644 Crawler/PulsatingFire.cpp diff --git a/Crawler/Animation.cpp b/Crawler/Animation.cpp index 72cc5c2c..52c0b1af 100644 --- a/Crawler/Animation.cpp +++ b/Crawler/Animation.cpp @@ -295,6 +295,12 @@ void sig::Animation::InitializeAnimations(){ Animate2D::FrameSequence meteor; meteor.AddFrame({&game->GFX_Meteor,{{0,0},{192,192}}}); ANIMATION_DATA[AnimationState::METEOR]=meteor; + + for(int i=0;i<5;i++){ + Animate2D::FrameSequence firering; + firering.AddFrame({&game->GFX_LightningSplash,{{i*24,0},{24,24}}}); + ANIMATION_DATA[AnimationState(AnimationState::FIRE_RING1+i)]=firering; + } } void sig::Animation::SetupPlayerAnimations(){ diff --git a/Crawler/Animation.h b/Crawler/Animation.h index 54963c55..9b0fff55 100644 --- a/Crawler/Animation.h +++ b/Crawler/Animation.h @@ -21,6 +21,7 @@ enum AnimationState{ LIGHTNING_BOLT,LIGHTNING_BOLT_PARTICLE1,LIGHTNING_BOLT_PARTICLE2,LIGHTNING_BOLT_PARTICLE3,LIGHTNING_BOLT_PARTICLE4, CHAIN_LIGHTNING,LIGHTNING_SPLASH, WIZARD_CAST_S,WIZARD_CAST_N,WIZARD_CAST_E,WIZARD_CAST_W,METEOR, + FIRE_RING1,FIRE_RING2,FIRE_RING3,FIRE_RING4,FIRE_RING5, }; namespace sig{ diff --git a/Crawler/Crawler.vcxproj b/Crawler/Crawler.vcxproj index 44184cbe..14353092 100644 --- a/Crawler/Crawler.vcxproj +++ b/Crawler/Crawler.vcxproj @@ -219,6 +219,7 @@ + diff --git a/Crawler/Crawler.vcxproj.filters b/Crawler/Crawler.vcxproj.filters index a4139623..ed9898bc 100644 --- a/Crawler/Crawler.vcxproj.filters +++ b/Crawler/Crawler.vcxproj.filters @@ -188,6 +188,9 @@ Source Files\Player Classes + + Source Files\Effects + diff --git a/Crawler/Effect.h b/Crawler/Effect.h index dbbaeadc..d3ceafc6 100644 --- a/Crawler/Effect.h +++ b/Crawler/Effect.h @@ -33,4 +33,12 @@ struct Meteor:Effect{ bool shakeField=false; bool Update(float fElapsedTime)override; void Draw()override; +}; + +struct PulsatingFire:Effect{ + PulsatingFire(vf2d pos,float lifetime,AnimationState animation,bool upperLevel,vf2d size={1,1},float fadeout=0.0f,vf2d spd={},Pixel col=WHITE,float rotation=0,float rotationSpd=0,bool additiveBlending=false); + std::vectorpulsatingFireValues; + float lastParticleTimer=0; + bool Update(float fElapsedTime)override; + void Draw()override; }; \ No newline at end of file diff --git a/Crawler/Meteor.cpp b/Crawler/Meteor.cpp index 300f0b76..dbf1f49e 100644 --- a/Crawler/Meteor.cpp +++ b/Crawler/Meteor.cpp @@ -4,6 +4,7 @@ #include "utils.h" INCLUDE_game +INCLUDE_MONSTER_LIST Meteor::Meteor(vf2d pos, float lifetime, AnimationState animation, bool upperLevel, vf2d size, float fadeout, vf2d spd, Pixel col, float rotation, float rotationSpd, bool additiveBlending) :Effect(pos,lifetime,animation,upperLevel,size,fadeout,spd,col,rotation,rotationSpd,additiveBlending),startLifetime(lifetime){ @@ -14,27 +15,35 @@ bool Meteor::Update(float fElapsedTime){ if(lifetime<=0&&!shakeField){ shakeField=true; game->SetupWorldShake(2); + vf2d meteorOffset=pos+vf2d{lifetime,-lifetime}*320-vf2d{0,GetFrame().GetSourceRect().size.y/4.f}; for(int i=0;i<650;i++){ float randomAngle=util::random(2*PI); float randomRange=100*size.x*(1-util::random(0.25))*(1-util::random(0.25)); float randomColorTintG=256-(util::random(128)+util::random(128)); float randomColorTint=util::random(128); - vf2d effectPos=pos+vf2d{cos(randomAngle),sin(randomAngle)}*randomRange-vf2d{0,GetFrame().GetSourceRect().size.y/2.f}; - game->AddEffect(std::make_unique(effectPos,0,AnimationState::DOT_PARTICLE,OnUpperLevel(),vf2d{util::random(2)+1,util::random(3)+1},util::random(3)+1,vf2d{util::random(10)-5,-util::random(20)-5},Pixel{255,uint8_t(randomColorTintG),uint8_t(randomColorTint),uint8_t(util::random(128)+128)},0,0,true),effectPos.y<(pos-vf2d{0,GetFrame().GetSourceRect().size.y/2.f}).y); + vf2d effectPos=vf2d{cos(randomAngle),sin(randomAngle)}*randomRange+meteorOffset; + game->AddEffect(std::make_unique(effectPos,0,AnimationState::DOT_PARTICLE,OnUpperLevel(),vf2d{util::random(2)+1,util::random(3)+1},util::random(3)+1,vf2d{util::random(10)-5,-util::random(20)-5},Pixel{255,uint8_t(randomColorTintG),uint8_t(randomColorTint),uint8_t(util::random(128)+128)},0,0,true),effectPos.yGetPlayer()->GetAttack()*9); + } + } + game->AddEffect(std::make_unique(pos,3,AnimationState::FIRE_RING1,OnUpperLevel(),vf2d{8,8},1),true); } return Effect::Update(fElapsedTime); } void Meteor::Draw(){ if(lifetime>0){ - vf2d scale=vf2d{192,64}/3.f*(startLifetime+1-lifetime)*0.5; + vf2d scale=vf2d{192,64}/3.f*(startLifetime+1-lifetime)*0.25*size; vf2d centerPoint=pos-vf2d{game->GFX_Circle.Sprite()->width*scale.x/2,game->GFX_Circle.Sprite()->height*scale.y/2}; game->view.DrawDecal(centerPoint,game->GFX_Circle.Decal(),scale,{0,0,0,192}); } - vf2d meteorOffset=pos+vf2d{lifetime,-lifetime}*320-vf2d{0,GetFrame().GetSourceRect().size.y/2.f}; + vf2d meteorOffset=pos+vf2d{lifetime,-lifetime}*320-vf2d{0,GetFrame().GetSourceRect().size.y/4.f}*size; if(lifetime<=0){ - meteorOffset=pos-vf2d{0,GetFrame().GetSourceRect().size.y/2.f}; + meteorOffset=pos-vf2d{0,GetFrame().GetSourceRect().size.y/4.f}*size; } game->view.DrawPartialRotatedDecal(meteorOffset,GetFrame().GetSourceImage()->Decal(),rotation,GetFrame().GetSourceRect().size/2,GetFrame().GetSourceRect().pos,GetFrame().GetSourceRect().size,size,{col.r,col.g,col.b,uint8_t(fadeout/original_fadeoutTime*255)}); } \ No newline at end of file diff --git a/Crawler/PulsatingFire.cpp b/Crawler/PulsatingFire.cpp new file mode 100644 index 00000000..5f88d406 --- /dev/null +++ b/Crawler/PulsatingFire.cpp @@ -0,0 +1,57 @@ +#include "Effect.h" +#include "DEFINES.h" +#include "Crawler.h" +#include "utils.h" + +INCLUDE_game +INCLUDE_ANIMATION_DATA + +PulsatingFire::PulsatingFire(vf2d pos, float lifetime, AnimationState animation, bool upperLevel, vf2d size, float fadeout, vf2d spd, Pixel col, float rotation, float rotationSpd, bool additiveBlending) + :Effect(pos,lifetime,animation,upperLevel,size,fadeout,spd,col,rotation,rotationSpd,additiveBlending),lastParticleTimer(lifetime){ + for(int i=0;i<8;i++){ + pulsatingFireValues.push_back(util::random(1)); + } +} + +bool PulsatingFire::Update(float fElapsedTime){ + lastParticleTimer-=fElapsedTime; + if(lastParticleTimer<=0){ + int particleCount=rand()%10+1; + for(int i=0;iAddEffect(std::make_unique(pos+vf2d{cos(randomAngle),sin(randomAngle)}*randomRange,0,AnimationState::DOT_PARTICLE,OnUpperLevel(),vf2d{util::random(2)+1,1},util::random(4)+2,vf2d{util::random(20)-5,-util::random(30)-10},Pixel{255,uint8_t(randomColorTintG),uint8_t(randomColorTint),uint8_t(util::random(128)+128)},0,0,true)); + } + lastParticleTimer=util::random(0.2)+0.025; + } + return Effect::Update(fElapsedTime); +} + +void PulsatingFire::Draw(){ + for(int i=0;i<8;i++){ + Animate2D::FrameSequence*effectSpr=nullptr; + switch(int(pulsatingFireValues[i]*5)){ + case 0:{ + effectSpr=&ANIMATION_DATA[AnimationState::FIRE_RING1]; + }break; + case 1:{ + effectSpr=&ANIMATION_DATA[AnimationState::FIRE_RING2]; + }break; + case 2:{ + effectSpr=&ANIMATION_DATA[AnimationState::FIRE_RING3]; + }break; + case 3:{ + effectSpr=&ANIMATION_DATA[AnimationState::FIRE_RING4]; + }break; + case 4:{ + effectSpr=&ANIMATION_DATA[AnimationState::FIRE_RING5]; + }break; + default: + effectSpr=&ANIMATION_DATA[AnimationState::FIRE_RING1]; + } + const Renderable*img=effectSpr->GetFrame(0).GetSourceImage(); + game->view.DrawPartialDecal(pos-effectSpr->GetFrame(0).GetSourceRect().size/2*size,img->Decal(),effectSpr->GetFrame(0).GetSourceRect().pos,effectSpr->GetFrame(0).GetSourceRect().size,size,{255,uint8_t(pulsatingFireValues[i]*256),0,uint8_t(63*(sin(3*lifetime+PI*pulsatingFireValues[i]))+64)}); + } +} \ No newline at end of file diff --git a/Crawler/Version.h b/Crawler/Version.h index 1c9f3581..7a705924 100644 --- a/Crawler/Version.h +++ b/Crawler/Version.h @@ -2,7 +2,7 @@ #define VERSION_MAJOR 0 #define VERSION_MINOR 2 #define VERSION_PATCH 0 -#define VERSION_BUILD 686 +#define VERSION_BUILD 712 #define stringify(a) stringify_(a) #define stringify_(a) #a diff --git a/Crawler/Wizard.cpp b/Crawler/Wizard.cpp index b8882156..19cb133f 100644 --- a/Crawler/Wizard.cpp +++ b/Crawler/Wizard.cpp @@ -121,7 +121,7 @@ void Wizard::InitializeClassAbilities(){ Wizard::ability3.action= [&](vf2d pos={}){ CastSpell(Wizard::ability3); - game->AddEffect(std::make_unique(pos,3,AnimationState::METEOR,OnUpperLevel(),vf2d{1.75,1.75},2)); + game->AddEffect(std::make_unique(pos,3,AnimationState::METEOR,OnUpperLevel(),vf2d{1,1},2)); return true; }; #pragma endregion