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