40 lines
1.3 KiB
C++
Raw Normal View History

2023-06-15 00:11:39 -05:00
#include "DEFINES.h"
#include "Effect.h"
#include "Crawler.h"
INCLUDE_ANIMATION_DATA
INCLUDE_game
2023-07-07 06:42:49 -05:00
Effect::Effect(vf2d pos,float lifetime,AnimationState animation,bool upperLevel,float size,float fadeout,vf2d spd,Pixel col)
:pos(pos),lifetime(lifetime),upperLevel(upperLevel),size(size),fadeout(fadeout),original_fadeoutTime(fadeout),spd(spd),col(col){
2023-06-15 00:11:39 -05:00
this->animation.AddState(animation,ANIMATION_DATA[animation]);
}
bool Effect::Update(float fElapsedTime){
lifetime-=fElapsedTime;
if(lifetime<=0){
fadeout-=fElapsedTime;
if(fadeout<=0){
return false;
}
}
2023-06-24 02:14:11 -07:00
pos+=spd*fElapsedTime;
2023-06-15 00:11:39 -05:00
animation.UpdateState(internal_animState,fElapsedTime);
return true;
2023-06-15 00:11:39 -05:00
}
void Effect::Draw(){
if(fadeout==0){
2023-07-06 04:35:40 -05:00
game->view.DrawPartialDecal(pos-GetFrame().GetSourceRect().size*size/2,GetFrame().GetSourceImage()->Decal(),GetFrame().GetSourceRect().pos,GetFrame().GetSourceRect().size,{size,size},col);
2023-06-15 00:11:39 -05:00
} else {
2023-07-06 04:35:40 -05:00
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)});
2023-06-15 00:11:39 -05:00
}
}
Animate2D::Frame Effect::GetFrame(){
return animation.GetFrame(internal_animState);
2023-07-07 06:42:49 -05:00
}
bool Effect::OnUpperLevel(){
return upperLevel;
2023-06-15 00:11:39 -05:00
}