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 <pg/Vector2.h>
24 #include "Effects/Effect.h"
25 #include "Effects/Gravity.h"
26 #include "Effects/GravityWell.h"
27 #include "Effects/Screen.h"
29 #include "input/inputManager.h"
30 #include "config/config.h"
32 /// ***** Private Variables *****
34 typedef std::set<Effect*> setEffect;
35 setEffect active_Effects;
37 GravityWell* pMouseWell;
39 /// ***** Initializers/Cleaners *****
43 pMouseWell = new GravityWell(Vector2(0,0));
45 active_Effects.insert(new Screen());
46 active_Effects.insert(new Gravity());
50 for( setEffect::iterator it = active_Effects.begin();
51 it != active_Effects.end();
58 /// ***** Public Methods *****
60 void effect::update(float)
64 void effect::handleInput()
66 if(cfg::mouseWellFollow())
67 pMouseWell->setPosition(input::mousePosition());
69 if(cfg::mouseWellOn())
70 active_Effects.insert(pMouseWell);
71 if(cfg::mouseWellOff())
72 active_Effects.erase(pMouseWell);
75 Vector2 effect::positionDelta(const PhysicsEntity* ppe, float fTimeStep)
79 for( setEffect::iterator it = active_Effects.begin();
80 it != active_Effects.end();
83 acc += (*it)->positionDelta(ppe, fTimeStep);
88 Vector2 effect::velocityDelta(const PhysicsEntity* ppe, float fTimeStep)
92 for( setEffect::iterator it = active_Effects.begin();
93 it != active_Effects.end();
96 acc += (*it)->velocityDelta(ppe, fTimeStep);
101 Vector2 effect::forceDelta(const PhysicsEntity* ppe, float fTimeStep)
105 for( setEffect::iterator it = active_Effects.begin();
106 it != active_Effects.end();
109 acc += (*it)->forceDelta(ppe, fTimeStep);