|
|
|
#include "DEFINES.h"
|
|
|
|
#include "Effect.h"
|
|
|
|
#include "Crawler.h"
|
|
|
|
|
|
|
|
INCLUDE_ANIMATION_DATA
|
|
|
|
INCLUDE_game
|
|
|
|
|
|
|
|
Effect::Effect(vf2d pos,float lifetime,AnimationState animation,float size,float fadeout,vf2d spd,Pixel col)
|
|
|
|
:pos(pos),lifetime(lifetime),size(size),fadeout(fadeout),original_fadeoutTime(fadeout),spd(spd),col(col){
|
|
|
|
this->animation.AddState(animation,ANIMATION_DATA[animation]);
|
|
|
|
}
|
|
|
|
|
|
|
|
bool Effect::Update(float fElapsedTime){
|
|
|
|
lifetime-=fElapsedTime;
|
|
|
|
if(lifetime<=0){
|
|
|
|
fadeout-=fElapsedTime;
|
|
|
|
if(fadeout<=0){
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
pos+=spd*fElapsedTime;
|
|
|
|
animation.UpdateState(internal_animState,fElapsedTime);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
void Effect::Draw(){
|
|
|
|
if(fadeout==0){
|
|
|
|
game->view.DrawPartialDecal(pos-GetFrame().GetSourceRect().size*size/2,GetFrame().GetSourceImage()->Decal(),GetFrame().GetSourceRect().pos,GetFrame().GetSourceRect().size,{size,size},col);
|
|
|
|
} else {
|
|
|
|
game->view.DrawPartialDecal(pos-GetFrame().GetSourceRect().size*size/2,GetFrame().GetSourceImage()->Decal(),GetFrame().GetSourceRect().pos,GetFrame().GetSourceRect().size,{size,size},{col.r,col.g,col.b,uint8_t(fadeout/original_fadeoutTime*255)});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
Animate2D::Frame Effect::GetFrame(){
|
|
|
|
return animation.GetFrame(internal_animState);
|
|
|
|
}
|