1 #include "PhysicsEntity.h"
4 #include "../effectManager.h"
5 #include "../Vector2.h"
8 /// ***** Constructors/Destructors *****
10 PhysicsEntity::PhysicsEntity(const Vector2& pos)
11 : Entity(pos), force(0,0), mass(1), CoR(1)
15 PhysicsEntity::~PhysicsEntity()
20 /// ***** Public Class Methods *****
22 void PhysicsEntity::update(float time_step)
24 position = positionAt(time_step);
25 velocity = velocityAt(time_step);
30 Vector2 PhysicsEntity::positionAt(float time_step) const
32 Vector2 newPosition = position;
33 Vector2 newVelocity = velocity;
34 Vector2 newForce = force;
36 newPosition += effect::positionDelta(this, time_step);
37 newVelocity += effect::velocityDelta(this, time_step);
38 newForce += effect::forceDelta(this, time_step);
40 return newForce/mass / 2 * time_step * time_step + newVelocity * time_step + newPosition;
43 Vector2 PhysicsEntity::velocityAt(float time_step) const
45 Vector2 newForce = force;
46 Vector2 newVelocity = velocity;
48 newForce += effect::forceDelta(this, time_step);
49 newVelocity += effect::velocityDelta(this, time_step);
51 return newForce/mass / 2 * time_step + newVelocity;
54 void PhysicsEntity::applyForce(const Vector2& force)
59 void PhysicsEntity::applyImpulse(const Vector2& impluse)