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 | ||
f32a9b7c PG |
20 | #include <pg/Vector2.h> |
21 | ||
f103ba70 PG |
22 | #include <set> |
23 | ||
33b8c69b | 24 | #include "Effects/Effect.h" |
f206d19d | 25 | #include "Effects/Gravity.h" |
46e842c7 | 26 | #include "Effects/GravityWell.h" |
2c18685d | 27 | #include "Effects/Screen.h" |
f206d19d | 28 | |
a823a800 | 29 | #include "input/inputManager.h" |
a860c0c7 | 30 | #include "config/config.h" |
46e842c7 | 31 | |
33b8c69b | 32 | /// ***** Private Variables ***** |
617dcc71 | 33 | |
f103ba70 PG |
34 | typedef std::set<Effect*> setEffect; |
35 | setEffect active_Effects; | |
33b8c69b | 36 | |
252b36a3 | 37 | GravityWell* pMouseWell; |
a823a800 | 38 | |
617dcc71 | 39 | /// ***** Initializers/Cleaners ***** |
33b8c69b PG |
40 | |
41 | void effect::init() | |
42 | { | |
252b36a3 | 43 | pMouseWell = new GravityWell(Vector2(0,0)); |
a823a800 | 44 | |
f103ba70 PG |
45 | active_Effects.insert(new Screen()); |
46 | active_Effects.insert(new Gravity()); | |
33b8c69b PG |
47 | } |
48 | void effect::clean() | |
49 | { | |
f103ba70 PG |
50 | for( setEffect::iterator it = active_Effects.begin(); |
51 | it != active_Effects.end(); | |
52 | it++ ) | |
33b8c69b | 53 | { |
f103ba70 | 54 | // TODO !!!!!!!!! |
33b8c69b | 55 | } |
33b8c69b | 56 | } |
f206d19d | 57 | |
617dcc71 PG |
58 | /// ***** Public Methods ***** |
59 | ||
a823a800 PG |
60 | void effect::update(float) |
61 | { | |
62 | ||
63 | } | |
64 | void effect::handleInput() | |
65 | { | |
f103ba70 | 66 | if(cfg::mouseWellFollow()) |
252b36a3 | 67 | pMouseWell->setPosition(input::mousePosition()); |
f103ba70 PG |
68 | |
69 | if(cfg::mouseWellOn()) | |
252b36a3 | 70 | active_Effects.insert(pMouseWell); |
f103ba70 | 71 | if(cfg::mouseWellOff()) |
252b36a3 | 72 | active_Effects.erase(pMouseWell); |
a823a800 PG |
73 | } |
74 | ||
252b36a3 | 75 | Vector2 effect::positionDelta(const PhysicsEntity* ppe, float fTimeStep) |
f206d19d | 76 | { |
33b8c69b PG |
77 | Vector2 acc(0,0); |
78 | ||
f103ba70 PG |
79 | for( setEffect::iterator it = active_Effects.begin(); |
80 | it != active_Effects.end(); | |
81 | it++ ) | |
33b8c69b | 82 | { |
252b36a3 | 83 | acc += (*it)->positionDelta(ppe, fTimeStep); |
33b8c69b PG |
84 | } |
85 | ||
86 | return acc; | |
f206d19d | 87 | } |
252b36a3 | 88 | Vector2 effect::velocityDelta(const PhysicsEntity* ppe, float fTimeStep) |
f206d19d | 89 | { |
33b8c69b PG |
90 | Vector2 acc(0,0); |
91 | ||
f103ba70 PG |
92 | for( setEffect::iterator it = active_Effects.begin(); |
93 | it != active_Effects.end(); | |
94 | it++ ) | |
33b8c69b | 95 | { |
252b36a3 | 96 | acc += (*it)->velocityDelta(ppe, fTimeStep); |
33b8c69b PG |
97 | } |
98 | ||
99 | return acc; | |
f206d19d | 100 | } |
252b36a3 | 101 | Vector2 effect::forceDelta(const PhysicsEntity* ppe, float fTimeStep) |
f206d19d | 102 | { |
33b8c69b PG |
103 | Vector2 acc(0,0); |
104 | ||
f103ba70 PG |
105 | for( setEffect::iterator it = active_Effects.begin(); |
106 | it != active_Effects.end(); | |
107 | it++ ) | |
33b8c69b | 108 | { |
252b36a3 | 109 | acc += (*it)->forceDelta(ppe, fTimeStep); |
33b8c69b PG |
110 | } |
111 | ||
112 | return acc; | |
f206d19d | 113 | } |