8#ifndef ANIMATION_GANIMATION_H_
9#define ANIMATION_GANIMATION_H_
37 template<
typename First,
typename Second>
41 triggerfunc = [first, second]() ->
bool {
return *first < *second; };
44 triggerfunc = [first, second]() ->
bool {
return *first > *second; };
47 triggerfunc = [first, second]() ->
bool {
return *first <= *second; };
50 triggerfunc = [first, second]() ->
bool {
return *first >= *second; };
53 triggerfunc = [first, second]() ->
bool {
return *first == *second; };
56 triggerfunc = [first]() ->
bool {
return *first ==
false; };
59 triggerfunc = [first]() ->
bool {
return *first ==
true; };
70 std::function<bool()> triggerfunc;
122 void draw(
int x,
int y,
int w,
int h);
134 std::shared_ptr<gAnimationTrigger> trigger;
137 std::vector<std::unique_ptr<gImage>> frames;
186template<
typename First,
typename Second>
188 return std::shared_ptr<gAnimationTrigger>(
new gAnimationTrigger{first, second, cond});
194#define TRIGGER_NONE nullptr
195#define TRIGGER_LESS(First, Second) createTrigger(First, Second, TriggerCondition::LESS)
196#define TRIGGER_GREATER(First, Second) createTrigger(First, Second, TriggerCondition::GREATER)
197#define TRIGGER_LESS_EQUAL(First, Second) createTrigger(First, Second, TriggerCondition::LESS_EQUAL)
198#define TRIGGER_GREATER_EQUAL(First, Second) createTrigger(First, Second, TriggerCondition::GREATER_EQUAL)
199#define TRIGGER_EQUAL(First, Second) createTrigger(First, Second, TriggerCondition::EQUAL)
200#define TRIGGER_FALSE(First, Second) createTrigger(First, Second, TriggerCondition::FALSE)
201#define TRIGGER_TRUE(First, Second) createTrigger(First, Second, TriggerCondition::TRUE)
Definition gSpriteAnimation.h:35
bool isConditionTriggered()
Definition gSpriteAnimation.h:66
constexpr gAnimationTrigger(First *first, Second *second, TriggerCondition cond)
Definition gSpriteAnimation.h:38
Definition gSpriteAnimation.h:73
virtual ~gSpriteAnimation()
void draw(int x, int y, int w, int h)
void loadFrame(const std::string &framePath)
bool isConditionTriggered()
void setLoop(bool isLooped)
void addConditionTrigger(std::shared_ptr< gAnimationTrigger > trigger)
TriggerCondition
Definition gSpriteAnimation.h:16
@ GREATER
Definition gSpriteAnimation.h:18
@ GREATER_EQUAL
Definition gSpriteAnimation.h:20
@ EQUAL
Definition gSpriteAnimation.h:21
@ MAX_TRIGGER_CONDITIONS
Definition gSpriteAnimation.h:25
@ LESS
Definition gSpriteAnimation.h:17
@ FALSE
Definition gSpriteAnimation.h:22
@ TRUE
Definition gSpriteAnimation.h:23
@ LESS_EQUAL
Definition gSpriteAnimation.h:19
std::shared_ptr< gAnimationTrigger > createTrigger(First *first, Second *second, TriggerCondition cond)
Definition gSpriteAnimation.h:187
gSpriteAnimation * createSpriteAnim(std::shared_ptr< gAnimationTrigger > animationTrigger)