#include "../debug.h"
#include "../Vector2.h"
-#include "../Effects/Effect.h"
-#include "../Effects/Gravity.h"
+#include "../effectManager.h"
/// ***** Public Class Methods *****
PhysicsEntity::PhysicsEntity(const Vector2& pos)
: Entity(pos), force(0,0), mass(1), CoR(1)
{
- g = new Gravity();
}
PhysicsEntity::~PhysicsEntity()
{
- delete g;
}
void PhysicsEntity::update(float time_step)
Vector2 newVelocity = velocity;
Vector2 newForce = force;
- newPosition += g->positionDelta(this, time_step);
- newVelocity += g->velocityDelta(this, time_step);
- newForce += g->forceDelta(this, time_step);
+ newPosition += effect::positionDelta(this, time_step);
+ newVelocity += effect::velocityDelta(this, time_step);
+ newForce += effect::forceDelta(this, time_step);
return newForce/mass / 2 * time_step * time_step + newVelocity * time_step + newPosition;
}
Vector2 newForce = force;
Vector2 newVelocity = velocity;
- newForce += g->forceDelta(this, time_step);
- newVelocity += g->velocityDelta(this, time_step);
+ newForce += effect::forceDelta(this, time_step);
+ newVelocity += effect::velocityDelta(this, time_step);
return newForce/mass / 2 * time_step + newVelocity;
}
--- /dev/null
+#include "effectManager.h"
+
+#include "Effects/Gravity.h"
+
+Gravity* g = new Gravity();
+
+Vector2 effect::positionDelta(const PhysicsEntity* e, float time_step)
+{
+ return g->positionDelta(e, time_step);
+}
+Vector2 effect::velocityDelta(const PhysicsEntity* e, float time_step)
+{
+ return g->velocityDelta(e, time_step);
+}
+Vector2 effect::forceDelta(const PhysicsEntity* e, float time_step)
+{
+ return g->forceDelta(e, time_step);
+}
--- /dev/null
+#ifndef EFFECTMANAGER_H
+#define EFFECTMANAGER_H
+
+#include "Vector2.h"
+#include "Entities/PhysicsEntity.h"
+
+/// ***** Header Methods *****
+namespace effect
+{
+ Vector2 positionDelta(const PhysicsEntity*, float);
+ Vector2 velocityDelta(const PhysicsEntity*, float);
+ Vector2 forceDelta(const PhysicsEntity*, float);
+}
+#endif // EFFECTMANAGER_H