1 #include "PhysicsEntity.h"
4 #include "../Vector2.h"
5 #include "../effectManager.h"
7 /// ***** Public Class Methods *****
8 PhysicsEntity::PhysicsEntity(const Vector2& pos)
9 : Entity(pos), force(0,0), mass(1), CoR(1)
12 PhysicsEntity::~PhysicsEntity()
16 void PhysicsEntity::update(float time_step)
18 position = positionAt(time_step);
19 velocity = velocityAt(time_step);
24 Vector2 PhysicsEntity::positionAt(float time_step) const
26 Vector2 newPosition = position;
27 Vector2 newVelocity = velocity;
28 Vector2 newForce = force;
30 newPosition += effect::positionDelta(this, time_step);
31 newVelocity += effect::velocityDelta(this, time_step);
32 newForce += effect::forceDelta(this, time_step);
34 return newForce/mass / 2 * time_step * time_step + newVelocity * time_step + newPosition;
37 Vector2 PhysicsEntity::velocityAt(float time_step) const
39 Vector2 newForce = force;
40 Vector2 newVelocity = velocity;
42 newForce += effect::forceDelta(this, time_step);
43 newVelocity += effect::velocityDelta(this, time_step);
45 return newForce/mass / 2 * time_step + newVelocity;
48 void PhysicsEntity::applyForce(const Vector2& force)
53 void PhysicsEntity::applyImpulse(const Vector2& impluse)