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