parent
515c74aa9f
commit
7e543a3021
@ -0,0 +1,7 @@ |
|||||||
|
#pragma once |
||||||
|
#define INCLUDE_ANIMATION_DATA extern std::map<AnimationState,Animate2D::FrameSequence>ANIMATION_DATA; |
||||||
|
#define INCLUDE_MONSTER_LIST extern std::vector<Monster>MONSTER_LIST; |
||||||
|
#define INCLUDE_SPAWNER_LIST extern std::vector<MonsterSpawner>SPAWNER_LIST; |
||||||
|
#define INCLUDE_DAMAGENUMBER_LIST extern std::vector<DamageNumber>DAMAGENUMBER_LIST; |
||||||
|
#define INCLUDE_game extern Crawler*game; |
||||||
|
#define INCLUDE_MONSTER_DATA extern std::map<MonsterName,MonsterData>MONSTER_DATA; |
@ -0,0 +1,34 @@ |
|||||||
|
#include "DEFINES.h" |
||||||
|
#include "Effect.h" |
||||||
|
#include "Crawler.h" |
||||||
|
|
||||||
|
INCLUDE_ANIMATION_DATA |
||||||
|
INCLUDE_game |
||||||
|
|
||||||
|
Effect::Effect(vf2d pos,float lifetime,AnimationState animation,float fadeout) |
||||||
|
:pos(pos),lifetime(lifetime),fadeout(fadeout),original_fadeoutTime(fadeout){ |
||||||
|
this->animation.AddState(animation,ANIMATION_DATA[animation]); |
||||||
|
} |
||||||
|
|
||||||
|
bool Effect::Update(float fElapsedTime){ |
||||||
|
lifetime-=fElapsedTime; |
||||||
|
if(lifetime<=0){ |
||||||
|
fadeout-=fElapsedTime; |
||||||
|
if(fadeout<=0){ |
||||||
|
return false; |
||||||
|
} |
||||||
|
} |
||||||
|
animation.UpdateState(internal_animState,fElapsedTime); |
||||||
|
} |
||||||
|
|
||||||
|
void Effect::Draw(){ |
||||||
|
if(fadeout==0){ |
||||||
|
game->view.DrawPartialDecal(pos-GetFrame().GetSourceRect().size/2,GetFrame().GetSourceImage()->Decal(),GetFrame().GetSourceRect().pos,GetFrame().GetSourceRect().size); |
||||||
|
} else { |
||||||
|
game->view.DrawPartialDecal(pos-GetFrame().GetSourceRect().size/2,GetFrame().GetSourceImage()->Decal(),GetFrame().GetSourceRect().pos,GetFrame().GetSourceRect().size,{1,1},{255,255,255,uint8_t(fadeout/original_fadeoutTime*255)}); |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
Animate2D::Frame Effect::GetFrame(){ |
||||||
|
return animation.GetFrame(internal_animState); |
||||||
|
} |
@ -0,0 +1,18 @@ |
|||||||
|
#pragma once |
||||||
|
#include "olcPixelGameEngine.h" |
||||||
|
#include "Animation.h" |
||||||
|
#include "olcUTIL_Animate2D.h" |
||||||
|
|
||||||
|
struct Effect{ |
||||||
|
vf2d pos; |
||||||
|
float lifetime; |
||||||
|
float fadeout; |
||||||
|
Effect(vf2d pos,float lifetime,AnimationState animation,float fadeout=0.0f); |
||||||
|
bool Update(float fElapsedTime); |
||||||
|
Animate2D::Frame GetFrame(); |
||||||
|
void Draw(); |
||||||
|
private: |
||||||
|
Animate2D::Animation<AnimationState>animation; |
||||||
|
Animate2D::AnimationState internal_animState; |
||||||
|
float original_fadeoutTime; |
||||||
|
}; |
Before Width: | Height: | Size: 912 B After Width: | Height: | Size: 10 KiB |
Before Width: | Height: | Size: 812 B After Width: | Height: | Size: 10 KiB |
@ -0,0 +1,9 @@ |
|||||||
|
// Hint files help the Visual Studio IDE interpret Visual C++ identifiers |
||||||
|
// such as names of functions and macros. |
||||||
|
// For more information see https://go.microsoft.com/fwlink/?linkid=865984 |
||||||
|
#define INCLUDE_ANIMATION_DATA |
||||||
|
#define INCLUDE_SPAWNER_LIST |
||||||
|
#define INCLUDE_DAMAGENUMBER_LIST |
||||||
|
#define INCLUDE_game |
||||||
|
#define INCLUDE_MONSTER_LIST |
||||||
|
#define INCLUDE_MONSTER_DATA |
Loading…
Reference in new issue