]> Dogcows Code - chaz/yoink/blobdiff - src/Character.cc
spring experiments
[chaz/yoink] / src / Character.cc
index 1b184fa2d0160ad353ef3645823d25626397b3cf..4ce11052274d0a0d9a23e378e3f5d7302ebd729a 100644 (file)
@@ -39,8 +39,10 @@ Character::Character(const std::string& name) :
        current.mass = 1.0;
        current.inverseMass = 1.0 / current.mass;
 
-       current.force = Mf::Vector2(0.0, -120.0);
+       // gravity
+       //current.force = Mf::Vector2(0.0, -120.0);
 
+       // starting position
        current.position = Mf::Vector2(64.0, 64.0);
        current.momentum = Mf::Vector2(0.0, 0.0);
        current.recalculate();
@@ -50,16 +52,27 @@ Character::Character(const std::string& name) :
        updateContainers();
 }
 
-Character::~Character()
-{
-       //delete texture;
-       //delete anim;
-}
-
 
 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.018538 seconds and 4 git commands to generate.