current.inverseMass = 1.0 / current.mass;
// gravity
- current.force = Mf::Vector2(0.0, -120.0);
+ //current.force = Mf::Vector2(0.0, -120.0);
// starting position
current.position = Mf::Vector2(64.0, 64.0);
void Character::update(Mf::Scalar t, Mf::Scalar dt)
{
previous = current;
+
+ Mf::Scalar epsilon = 100.0;
+
+ //current.momentum = Mf::Vector2(0.0, -120.0);
+ current.momentum = -5 * (current.position - Mf::Vector2(500.0, 200.0))
+ - 2.0 * current.velocity;
+ current.recalculate();
+ std::cout << "force: " << current.momentum << std::endl;
+
+ //if (std::abs(current.force[0]) < epsilon && std::abs(current.force[1]) < epsilon &&
+ //std::abs(current.velocity[0]) < epsilon && std::abs(current.velocity[1]) < epsilon)
+ //{
+ //current.force = Mf::Vector2(0.0, 0.0);
+ //current.velocity = Mf::Vector2(0.0, 0.0);
+ //current.momentum = Mf::Vector2(0.0, 0.0);
+ //}
+
Mf::integrate<State,Derivative>(current, t, dt);
animation_.update(t, dt);
}
+//template<typename T>
+//inline T spring(Scalar k, Scalar b)
+//{
+ //current.force = -15 * (current.position - Mf::Vector2(200.0, 200.0))
+ //- 15.0 * current.velocity;
+ //return
+//}
+
+
} // namespace Mf
#endif // _MOOF_RK4_HH_