return acc;
}
+
+void GravityWell::setPosition(const Vector2& pos)
+{
+ position = pos;
+}
class GravityWell: public Effect
{
public:
- GravityWell(const Vector2& pos);
+ GravityWell(const Vector2&);
~GravityWell();
Vector2 forceDelta(const PhysicsEntity*, float) const;
+ void setPosition(const Vector2&);
+
private:
Vector2 position;
};
Vector2 Screen::positionDelta(const PhysicsEntity* e, float time_step) const
{
const Vector2& pos = e->positionRaw();
- const Vector2& velo = e->velocityRaw();
Vector2 acc(0,0);
#include "Effects/Screen.h"
#include "Vector2.h"
+#include "input/inputManager.h"
/// ***** Private Variables *****
Effect** effects;
int numEffects;
+GravityWell* mouseWell;
+
/// ***** Initializers/Cleaners *****
void effect::init()
numEffects = 3;
effects = new Effect*[numEffects]();
- effects[0] = new Gravity();
- effects[1] = new GravityWell(Vector2(400,400));
+ mouseWell = new GravityWell(input::mousePosition());
+
+ effects[0] = mouseWell;
+ effects[1] = new Gravity();
effects[2] = new Screen();
}
void effect::clean()
/// ***** Public Methods *****
+void effect::update(float)
+{
+
+}
+void effect::handleInput()
+{
+ mouseWell->setPosition(input::mousePosition());
+}
+
Vector2 effect::positionDelta(const PhysicsEntity* e, float time_step)
{
Vector2 acc(0,0);
void init();
void clean();
+ void update(float);
+ void handleInput();
+
Vector2 positionDelta(const PhysicsEntity*, float);
Vector2 velocityDelta(const PhysicsEntity*, float);
Vector2 forceDelta(const PhysicsEntity*, float);
#include "Entities/PhysicsEntity.h"
#include "collisionHandler.h"
+#include "effectManager.h"
/// ***** Private Method Headers *****
void manager::handleInput()
{
- // TODO
+ effect::handleInput();
}
void manager::update(float time_step)
{
+ effect::update(time_step);
+
updateParticles(time_step);
updatePhysics(time_step);
}
}
}
+Vector2 input::mousePosition()
+{
+ int x;
+ int y;
+
+ SDL_GetMouseState(&x, &y);
+
+ return Vector2(x,y);
+}
+
bool input::isPressed(Uint8 key)
{
return keyState[key] == isP || keyState[key] == wasP;
#define INPUT_H
#include <SDL/SDL.h>
+#include "../Vector2.h"
/// ***** Header Methods *****
void update();
+ Vector2 mousePosition();
+
bool isPressed(Uint8);
bool isReleased(Uint8);