]> git.tdb.fi Git - libs/game.git/blob - examples/bassteroids/source/rigidbody.h
Implement a simple physics system in Bassteroids
[libs/game.git] / examples / bassteroids / source / rigidbody.h
1 #ifndef RIGIDBODY_H_
2 #define RIGIDBODY_H_
3
4 #include <msp/game/component.h>
5 #include <msp/geometry/angle.h>
6 #include <msp/linal/vector.h>
7
8 struct RigidBodySetup
9 {
10         float mass = 1.0f;
11 };
12
13 class RigidBody: public Msp::Game::Component
14 {
15 public:
16         using Setup = RigidBodySetup;
17
18 private:
19         const Setup &setup;
20         Msp::LinAl::Vector<float, 2> velocity;
21
22 public:
23         RigidBody(Msp::Game::Handle<Msp::Game::Entity>, const Setup &);
24
25         float get_mass() const { return setup.mass; }
26         void set_velocity(const Msp::LinAl::Vector<float, 2> &);
27         const Msp::LinAl::Vector<float, 2> &get_velocity() const { return velocity; }
28 };
29
30 #endif