spring experiments
[chaz/yoink] / src / Character.cc
index c7de260d6cb61190e5ceaf60b2be6701b455f309..4ce11052274d0a0d9a23e378e3f5d7302ebd729a 100644 (file)
@@ -40,7 +40,7 @@ Character::Character(const std::string& name) :
        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);
@@ -56,6 +56,23 @@ Character::Character(const std::string& name) :
 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);
This page took 0.018061 seconds and 4 git commands to generate.