2 * Copyright (C) 2008 Patrik Gornicz, Gornicz_P (at) hotmail (dot) com.
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.
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.
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/>.
18 #include "effectManager.h"
20 #include <bear/Vector2.h>
25 #include "Effects/Effect.h"
26 #include "Effects/Gravity.h"
27 #include "Effects/GravityWell.h"
28 #include "Effects/Screen.h"
30 #include "input/inputManager.h"
31 #include "config/config.h"
33 /// ***** Private Variables *****
35 typedef std::set<Effect*> setEffect;
36 setEffect active_Effects;
38 GravityWell* pMouseWell;
40 /// ***** Initializers/Cleaners *****
44 pMouseWell = new GravityWell(Vector2(0,0));
46 active_Effects.insert(new Screen());
47 active_Effects.insert(new Gravity());
51 for( setEffect::iterator it = active_Effects.begin();
52 it != active_Effects.end();
59 /// ***** Public Methods *****
61 void effect::update(float)
65 void effect::handleInput()
67 if(cfg::mouseWellFollow())
68 pMouseWell->setPosition(input::mousePosition());
70 if(cfg::mouseWellOn())
71 active_Effects.insert(pMouseWell);
72 if(cfg::mouseWellOff())
73 active_Effects.erase(pMouseWell);
76 Vector2 effect::positionDelta(const PhysicsEntity* ppe, float fTimeStep)
80 for( setEffect::iterator it = active_Effects.begin();
81 it != active_Effects.end();
84 acc += (*it)->positionDelta(ppe, fTimeStep);
89 Vector2 effect::velocityDelta(const PhysicsEntity* ppe, float fTimeStep)
93 for( setEffect::iterator it = active_Effects.begin();
94 it != active_Effects.end();
97 acc += (*it)->velocityDelta(ppe, fTimeStep);
102 Vector2 effect::forceDelta(const PhysicsEntity* ppe, float fTimeStep)
106 for( setEffect::iterator it = active_Effects.begin();
107 it != active_Effects.end();
110 acc += (*it)->forceDelta(ppe, fTimeStep);