Commit | Line | Data |
---|---|---|
e68f847b PG |
1 | /* |
2 | * Copyright (C) 2008 Patrik Gornicz, Gornicz_P (at) hotmail (dot) com. | |
3 | * | |
4 | * This program is free software: you can redistribute it and/or modify | |
5 | * it under the terms of the GNU General Public License as published by | |
6 | * the Free Software Foundation, either version 3 of the License, or | |
7 | * (at your option) any later version. | |
8 | * | |
9 | * This program is distributed in the hope that it will be useful, | |
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
12 | * GNU General Public License for more details. | |
13 | * | |
14 | * You should have received a copy of the GNU General Public License | |
15 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | |
16 | */ | |
17 | ||
f206d19d PG |
18 | #include "effectManager.h" |
19 | ||
33b8c69b | 20 | #include "Effects/Effect.h" |
f206d19d | 21 | #include "Effects/Gravity.h" |
2c18685d | 22 | #include "Effects/Screen.h" |
f206d19d | 23 | |
33b8c69b | 24 | /// ***** Private Variables ***** |
617dcc71 | 25 | |
33b8c69b PG |
26 | Effect** effects; |
27 | int numEffects; | |
28 | ||
617dcc71 | 29 | /// ***** Initializers/Cleaners ***** |
33b8c69b PG |
30 | |
31 | void effect::init() | |
32 | { | |
2c18685d | 33 | numEffects = 2; |
33b8c69b PG |
34 | effects = new Effect*[numEffects](); |
35 | ||
36 | effects[0] = new Gravity(); | |
2c18685d | 37 | effects[1] = new Screen(); |
33b8c69b PG |
38 | } |
39 | void effect::clean() | |
40 | { | |
41 | for(int i=0; i < numEffects; i++) | |
42 | { | |
43 | delete effects[i]; | |
44 | } | |
45 | ||
b8adb435 | 46 | delete[] effects; |
33b8c69b | 47 | } |
f206d19d | 48 | |
617dcc71 PG |
49 | /// ***** Public Methods ***** |
50 | ||
f206d19d PG |
51 | Vector2 effect::positionDelta(const PhysicsEntity* e, float time_step) |
52 | { | |
33b8c69b PG |
53 | Vector2 acc(0,0); |
54 | ||
55 | for(int i=0; i < numEffects; i++) | |
56 | { | |
57 | acc += effects[i]->positionDelta(e, time_step); | |
58 | } | |
59 | ||
60 | return acc; | |
f206d19d PG |
61 | } |
62 | Vector2 effect::velocityDelta(const PhysicsEntity* e, float time_step) | |
63 | { | |
33b8c69b PG |
64 | Vector2 acc(0,0); |
65 | ||
66 | for(int i=0; i < numEffects; i++) | |
67 | { | |
68 | acc += effects[i]->velocityDelta(e, time_step); | |
69 | } | |
70 | ||
71 | return acc; | |
f206d19d PG |
72 | } |
73 | Vector2 effect::forceDelta(const PhysicsEntity* e, float time_step) | |
74 | { | |
33b8c69b PG |
75 | Vector2 acc(0,0); |
76 | ||
77 | for(int i=0; i < numEffects; i++) | |
78 | { | |
79 | acc += effects[i]->forceDelta(e, time_step); | |
80 | } | |
81 | ||
82 | return acc; | |
f206d19d | 83 | } |