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" |
46e842c7 | 22 | #include "Effects/GravityWell.h" |
2c18685d | 23 | #include "Effects/Screen.h" |
f206d19d | 24 | |
46e842c7 PG |
25 | #include "Vector2.h" |
26 | ||
33b8c69b | 27 | /// ***** Private Variables ***** |
617dcc71 | 28 | |
33b8c69b PG |
29 | Effect** effects; |
30 | int numEffects; | |
31 | ||
617dcc71 | 32 | /// ***** Initializers/Cleaners ***** |
33b8c69b PG |
33 | |
34 | void effect::init() | |
35 | { | |
46e842c7 | 36 | numEffects = 3; |
33b8c69b PG |
37 | effects = new Effect*[numEffects](); |
38 | ||
39 | effects[0] = new Gravity(); | |
46e842c7 PG |
40 | effects[1] = new GravityWell(Vector2(400,400)); |
41 | effects[2] = new Screen(); | |
33b8c69b PG |
42 | } |
43 | void effect::clean() | |
44 | { | |
45 | for(int i=0; i < numEffects; i++) | |
46 | { | |
47 | delete effects[i]; | |
48 | } | |
49 | ||
b8adb435 | 50 | delete[] effects; |
33b8c69b | 51 | } |
f206d19d | 52 | |
617dcc71 PG |
53 | /// ***** Public Methods ***** |
54 | ||
f206d19d PG |
55 | Vector2 effect::positionDelta(const PhysicsEntity* e, float time_step) |
56 | { | |
33b8c69b PG |
57 | Vector2 acc(0,0); |
58 | ||
59 | for(int i=0; i < numEffects; i++) | |
60 | { | |
61 | acc += effects[i]->positionDelta(e, time_step); | |
62 | } | |
63 | ||
64 | return acc; | |
f206d19d PG |
65 | } |
66 | Vector2 effect::velocityDelta(const PhysicsEntity* e, float time_step) | |
67 | { | |
33b8c69b PG |
68 | Vector2 acc(0,0); |
69 | ||
70 | for(int i=0; i < numEffects; i++) | |
71 | { | |
72 | acc += effects[i]->velocityDelta(e, time_step); | |
73 | } | |
74 | ||
75 | return acc; | |
f206d19d PG |
76 | } |
77 | Vector2 effect::forceDelta(const PhysicsEntity* e, float time_step) | |
78 | { | |
33b8c69b PG |
79 | Vector2 acc(0,0); |
80 | ||
81 | for(int i=0; i < numEffects; i++) | |
82 | { | |
83 | acc += effects[i]->forceDelta(e, time_step); | |
84 | } | |
85 | ||
86 | return acc; | |
f206d19d | 87 | } |