Added lingering field effect.
This commit is contained in:
parent
88df322042
commit
73d29a2ab5
@ -295,6 +295,12 @@ void sig::Animation::InitializeAnimations(){
|
|||||||
Animate2D::FrameSequence meteor;
|
Animate2D::FrameSequence meteor;
|
||||||
meteor.AddFrame({&game->GFX_Meteor,{{0,0},{192,192}}});
|
meteor.AddFrame({&game->GFX_Meteor,{{0,0},{192,192}}});
|
||||||
ANIMATION_DATA[AnimationState::METEOR]=meteor;
|
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(){
|
void sig::Animation::SetupPlayerAnimations(){
|
||||||
|
@ -21,6 +21,7 @@ enum AnimationState{
|
|||||||
LIGHTNING_BOLT,LIGHTNING_BOLT_PARTICLE1,LIGHTNING_BOLT_PARTICLE2,LIGHTNING_BOLT_PARTICLE3,LIGHTNING_BOLT_PARTICLE4,
|
LIGHTNING_BOLT,LIGHTNING_BOLT_PARTICLE1,LIGHTNING_BOLT_PARTICLE2,LIGHTNING_BOLT_PARTICLE3,LIGHTNING_BOLT_PARTICLE4,
|
||||||
CHAIN_LIGHTNING,LIGHTNING_SPLASH,
|
CHAIN_LIGHTNING,LIGHTNING_SPLASH,
|
||||||
WIZARD_CAST_S,WIZARD_CAST_N,WIZARD_CAST_E,WIZARD_CAST_W,METEOR,
|
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{
|
namespace sig{
|
||||||
|
@ -219,6 +219,7 @@
|
|||||||
<ClCompile Include="Player.cpp" />
|
<ClCompile Include="Player.cpp" />
|
||||||
<ClCompile Include="Monster.cpp" />
|
<ClCompile Include="Monster.cpp" />
|
||||||
<ClCompile Include="MonsterData.cpp" />
|
<ClCompile Include="MonsterData.cpp" />
|
||||||
|
<ClCompile Include="PulsatingFire.cpp" />
|
||||||
<ClCompile Include="Ranger.cpp" />
|
<ClCompile Include="Ranger.cpp" />
|
||||||
<ClCompile Include="Thief.cpp" />
|
<ClCompile Include="Thief.cpp" />
|
||||||
<ClCompile Include="Trapper.cpp" />
|
<ClCompile Include="Trapper.cpp" />
|
||||||
|
@ -188,6 +188,9 @@
|
|||||||
<ClCompile Include="Ranger.cpp">
|
<ClCompile Include="Ranger.cpp">
|
||||||
<Filter>Source Files\Player Classes</Filter>
|
<Filter>Source Files\Player Classes</Filter>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
|
<ClCompile Include="PulsatingFire.cpp">
|
||||||
|
<Filter>Source Files\Effects</Filter>
|
||||||
|
</ClCompile>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<None Include="cpp.hint" />
|
<None Include="cpp.hint" />
|
||||||
|
@ -34,3 +34,11 @@ struct Meteor:Effect{
|
|||||||
bool Update(float fElapsedTime)override;
|
bool Update(float fElapsedTime)override;
|
||||||
void Draw()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::vector<float>pulsatingFireValues;
|
||||||
|
float lastParticleTimer=0;
|
||||||
|
bool Update(float fElapsedTime)override;
|
||||||
|
void Draw()override;
|
||||||
|
};
|
@ -4,6 +4,7 @@
|
|||||||
#include "utils.h"
|
#include "utils.h"
|
||||||
|
|
||||||
INCLUDE_game
|
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)
|
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){
|
: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){
|
if(lifetime<=0&&!shakeField){
|
||||||
shakeField=true;
|
shakeField=true;
|
||||||
game->SetupWorldShake(2);
|
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++){
|
for(int i=0;i<650;i++){
|
||||||
float randomAngle=util::random(2*PI);
|
float randomAngle=util::random(2*PI);
|
||||||
float randomRange=100*size.x*(1-util::random(0.25))*(1-util::random(0.25));
|
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 randomColorTintG=256-(util::random(128)+util::random(128));
|
||||||
float randomColorTint=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};
|
vf2d effectPos=vf2d{cos(randomAngle),sin(randomAngle)}*randomRange+meteorOffset;
|
||||||
game->AddEffect(std::make_unique<Effect>(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);
|
game->AddEffect(std::make_unique<Effect>(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<meteorOffset.y);
|
||||||
}
|
}
|
||||||
|
for(Monster&m:MONSTER_LIST){
|
||||||
|
float dist=sqrt(pow(pos.y-m.GetPos().y,2)+pow(pos.x-m.GetPos().x,2));
|
||||||
|
if(dist<=4*24){
|
||||||
|
m.Hurt(game->GetPlayer()->GetAttack()*9);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
game->AddEffect(std::make_unique<PulsatingFire>(pos,3,AnimationState::FIRE_RING1,OnUpperLevel(),vf2d{8,8},1),true);
|
||||||
}
|
}
|
||||||
return Effect::Update(fElapsedTime);
|
return Effect::Update(fElapsedTime);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Meteor::Draw(){
|
void Meteor::Draw(){
|
||||||
if(lifetime>0){
|
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};
|
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});
|
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){
|
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)});
|
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)});
|
||||||
}
|
}
|
57
Crawler/PulsatingFire.cpp
Normal file
57
Crawler/PulsatingFire.cpp
Normal file
@ -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;i<particleCount;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);
|
||||||
|
game->AddEffect(std::make_unique<Effect>(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)});
|
||||||
|
}
|
||||||
|
}
|
@ -2,7 +2,7 @@
|
|||||||
#define VERSION_MAJOR 0
|
#define VERSION_MAJOR 0
|
||||||
#define VERSION_MINOR 2
|
#define VERSION_MINOR 2
|
||||||
#define VERSION_PATCH 0
|
#define VERSION_PATCH 0
|
||||||
#define VERSION_BUILD 686
|
#define VERSION_BUILD 712
|
||||||
|
|
||||||
#define stringify(a) stringify_(a)
|
#define stringify(a) stringify_(a)
|
||||||
#define stringify_(a) #a
|
#define stringify_(a) #a
|
||||||
|
@ -121,7 +121,7 @@ void Wizard::InitializeClassAbilities(){
|
|||||||
Wizard::ability3.action=
|
Wizard::ability3.action=
|
||||||
[&](vf2d pos={}){
|
[&](vf2d pos={}){
|
||||||
CastSpell(Wizard::ability3);
|
CastSpell(Wizard::ability3);
|
||||||
game->AddEffect(std::make_unique<Meteor>(pos,3,AnimationState::METEOR,OnUpperLevel(),vf2d{1.75,1.75},2));
|
game->AddEffect(std::make_unique<Meteor>(pos,3,AnimationState::METEOR,OnUpperLevel(),vf2d{1,1},2));
|
||||||
return true;
|
return true;
|
||||||
};
|
};
|
||||||
#pragma endregion
|
#pragma endregion
|
||||||
|
Loading…
x
Reference in New Issue
Block a user