| 1 | #include "effectManager.h" |
| 2 | |
| 3 | #include "Effects/Effect.h" |
| 4 | #include "Effects/Gravity.h" |
| 5 | |
| 6 | /// ***** Private Variables ***** |
| 7 | Effect** effects; |
| 8 | int numEffects; |
| 9 | |
| 10 | /// ***** Public Methods ***** |
| 11 | |
| 12 | void effect::init() |
| 13 | { |
| 14 | numEffects = 1; |
| 15 | effects = new Effect*[numEffects](); |
| 16 | |
| 17 | effects[0] = new Gravity(); |
| 18 | } |
| 19 | void effect::clean() |
| 20 | { |
| 21 | for(int i=0; i < numEffects; i++) |
| 22 | { |
| 23 | delete effects[i]; |
| 24 | } |
| 25 | |
| 26 | delete effects; |
| 27 | } |
| 28 | |
| 29 | Vector2 effect::positionDelta(const PhysicsEntity* e, float time_step) |
| 30 | { |
| 31 | Vector2 acc(0,0); |
| 32 | |
| 33 | for(int i=0; i < numEffects; i++) |
| 34 | { |
| 35 | acc += effects[i]->positionDelta(e, time_step); |
| 36 | } |
| 37 | |
| 38 | return acc; |
| 39 | } |
| 40 | Vector2 effect::velocityDelta(const PhysicsEntity* e, float time_step) |
| 41 | { |
| 42 | Vector2 acc(0,0); |
| 43 | |
| 44 | for(int i=0; i < numEffects; i++) |
| 45 | { |
| 46 | acc += effects[i]->velocityDelta(e, time_step); |
| 47 | } |
| 48 | |
| 49 | return acc; |
| 50 | } |
| 51 | Vector2 effect::forceDelta(const PhysicsEntity* e, float time_step) |
| 52 | { |
| 53 | Vector2 acc(0,0); |
| 54 | |
| 55 | for(int i=0; i < numEffects; i++) |
| 56 | { |
| 57 | acc += effects[i]->forceDelta(e, time_step); |
| 58 | } |
| 59 | |
| 60 | return acc; |
| 61 | } |