The open source repository for the action RPG game in development by Sig Productions titled 'Adventures in Lestoria'!
https://forums.lestoria.net
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
57 lines
2.3 KiB
57 lines
2.3 KiB
1 year ago
|
#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)});
|
||
|
}
|
||
|
}
|