]> git.tdb.fi Git - libs/game.git/blobdiff - examples/bassteroids/source/rigidbody.h
Allow external forces and torques to be added on rigid bodies
[libs/game.git] / examples / bassteroids / source / rigidbody.h
index 6225500237c79f69eb0367994ca4f363cd585c48..aaffdc03c19eec0f18d131d88dd773d6aa8633d6 100644 (file)
@@ -20,6 +20,8 @@ private:
        const Setup &setup;
        Msp::LinAl::Vector<float, 2> velocity;
        Msp::Geometry::Angle<float> angular_velocity;
+       Msp::LinAl::Vector<float, 2> force;
+       float torque = 0.0f;
 
 public:
        RigidBody(Msp::Game::Handle<Msp::Game::Entity>, const Setup &);
@@ -28,8 +30,14 @@ public:
        float get_moment_of_inertia() const { return setup.moment_of_inertia; }
        void set_velocity(const Msp::LinAl::Vector<float, 2> &);
        void set_angular_velocity(Msp::Geometry::Angle<float>);
+       void add_force(const Msp::LinAl::Vector<float, 2> &);
+       void add_force(const Msp::LinAl::Vector<float, 2> &, const Msp::LinAl::Vector<float, 2> &);
+       void add_torque(float);
+       void clear_forces();
        const Msp::LinAl::Vector<float, 2> &get_velocity() const { return velocity; }
        Msp::Geometry::Angle<float> get_angular_velocity() const { return angular_velocity; }
+       const Msp::LinAl::Vector<float, 2> &get_force() const { return force; }
+       float get_torque() const { return torque; }
 };
 
 #endif