]> git.tdb.fi Git - libs/game.git/blobdiff - examples/bassteroids/source/rigidbody.h
Add rotation to physics simulation
[libs/game.git] / examples / bassteroids / source / rigidbody.h
index 8a7a5b3568a6b75920366480687161c65360f95f..6225500237c79f69eb0367994ca4f363cd585c48 100644 (file)
@@ -8,6 +8,7 @@
 struct RigidBodySetup
 {
        float mass = 1.0f;
+       float moment_of_inertia = 0.5f;
 };
 
 class RigidBody: public Msp::Game::Component
@@ -18,13 +19,17 @@ public:
 private:
        const Setup &setup;
        Msp::LinAl::Vector<float, 2> velocity;
+       Msp::Geometry::Angle<float> angular_velocity;
 
 public:
        RigidBody(Msp::Game::Handle<Msp::Game::Entity>, const Setup &);
 
        float get_mass() const { return setup.mass; }
+       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>);
        const Msp::LinAl::Vector<float, 2> &get_velocity() const { return velocity; }
+       Msp::Geometry::Angle<float> get_angular_velocity() const { return angular_velocity; }
 };
 
 #endif