TurtleBrains  0.3.1
High quality, portable, C++ framework for rapid 2D game development.
tbx_basic_behaviors.h
1 
9 #ifndef _TurtleBrains_BasicBehaviors_h_
10 #define _TurtleBrains_BasicBehaviors_h_
11 
12 #include "../../game/tb_entity_behavior_interface.h"
13 #include "../../game/tb_game_timer.h"
14 
15 namespace TurtleBrainsExpress
16 {
17  namespace Behaviors
18  {
19 
25  {
26  public:
33  DelayBehavior(tbGame::Entity& entity, const tbGame::GameTimer& delayTimer);
34 
38  virtual ~DelayBehavior(void);
39 
43  virtual void OnSimulate(void) override;
44 
45  private:
46  tbGame::GameTimer mDelayTimer;
47  };
48 
49 
56  {
57  public:
63  explicit KillBehavior(tbGame::Entity& entity);
64 
68  virtual ~KillBehavior(void);
69 
73  virtual void OnSimulate(void) override;
74 
75  private:
76  };
77 
78 
84  {
85  public:
95  explicit FlickerForBehavior(tbGame::Entity& entity, const tbGame::GameTimer& flickerToggleTime,
96  const tbGame::GameTimer& forTimer, const bool visibleOnPop = true);
97 
101  virtual ~FlickerForBehavior(void);
102 
107  virtual void OnRemove(void) override;
108 
114  virtual void OnSimulate(void) override;
115 
116  private:
117  const tbGame::GameTimer mTimeBetweenFlickers;
118  tbGame::GameTimer mTimeRemaining;
119  tbGame::GameTimer mFlickerTimer;
120  const bool mIsVisibleOnPop;
121  };
122 
123  namespace Unstable
124  {
125 
126  template<typename Type> class SetVariableBehavior : public tbGame::EntityBehaviorInterface
127  {
128  public:
129  inline SetVariableBehavior(tbGame::Entity& entity, Type& variableReference, const Type setValue) :
131  mVariableReference(variableReference),
132  mSetValue(setValue)
133  {
134  }
135 
136  inline virtual ~SetVariableBehavior(void)
137  {
138  }
139 
140  inline virtual void OnResume(void) override
141  {
142  mVariableReference = mSetValue;
144  }
145 
146  inline virtual void OnSimulate(void) override
147  {
148  mVariableReference = mSetValue;
150  }
151 
152  private:
153  Type& mVariableReference;
154  const Type mSetValue;
155  };
156 
157  }; /* namespace Unstable */
158 
159  }; /* namespace Behaviors */
160 }; /* namespace TurtleBrainsExpress */
161 
163 
164 #endif /* _TurtleBrains_BasicBehaviors_h_ */
Definition: tb_entity.h:46
Entity & mEntity
Definition: tb_entity_behavior_interface.h:46
Definition: tbx_basic_behaviors.h:83
Definition: tbx_basic_behaviors.h:24
Definition: tb_entity_behavior_interface.h:25
virtual void OnSimulate(void) override
A collection of objects and functions to express games quickly.
virtual void OnSimulate(void) override
FlickerForBehavior(tbGame::Entity &entity, const tbGame::GameTimer &flickerToggleTime, const tbGame::GameTimer &forTimer, const bool visibleOnPop=true)
virtual void OnResume(void) override
Definition: tbx_basic_behaviors.h:140
Definition: tbx_basic_behaviors.h:55
DelayBehavior(tbGame::Entity &entity, const tbGame::GameTimer &delayTimer)
Contains high-level objects to control the entities in game worlds.
virtual void OnSimulate(void) override
Definition: tbx_basic_behaviors.h:146
Definition: tb_game_timer.h:25