X-Git-Url: https://git.dogcows.com/gitweb?p=chaz%2Fyoink;a=blobdiff_plain;f=src%2FCharacter.cc;fp=src%2FCharacter.cc;h=a29e63d792fd50d17935f6dc1d3bb82067cc2903;hp=b26f2d4f06b2432da563d7c791594d26ecdc6530;hb=bc2bc12125d6c223d2935557e01926fe21166e38;hpb=23d8f7a5fbd1eca7f46f2342c20ac5e28ae0128a diff --git a/src/Character.cc b/src/Character.cc index b26f2d4..a29e63d 100644 --- a/src/Character.cc +++ b/src/Character.cc @@ -56,17 +56,21 @@ private: Mf::Vector2 location; }; -struct WindResistenceForce +struct ResistanceForce { + explicit ResistanceForce(Mf::Scalar scale = 1.0) : + k(scale) {} + const Mf::Vector2& operator () (const Mf::LinearState<2>& state) { - force = -2.0 * state.velocity; + force = -k * state.velocity; return force; } private: - Mf::Vector2 force; + Mf::Vector2 force; + Mf::Scalar k; }; @@ -82,7 +86,7 @@ Character::Character(const std::string& name) : // gravity current.force = Mf::Vector2(0.0, 000.0); current.forces.push_back(SpringForce(Mf::Vector2(500.0, 200.0))); - current.forces.push_back(WindResistenceForce()); + current.forces.push_back(ResistanceForce(4.0)); current.forces.push_back(Mf::LinearState<2>::GravityForce(-2000.0)); // starting position @@ -114,10 +118,7 @@ void Character::update(Mf::Scalar t, Mf::Scalar dt) //Mf::euler(current, t, dt); - //current.force = Mf::Vector2(0.0, -2000.0); - current.force = userForce; current.integrate(t, dt); - animation.update(t, dt); }