]> git.tdb.fi Git - libs/game.git/blob - examples/bassteroids/source/physicalentity.h
Implement a simple physics system in Bassteroids
[libs/game.git] / examples / bassteroids / source / physicalentity.h
1 #ifndef PHYSICALENTITY_H_
2 #define PHYSICALENTITY_H_
3
4 #include <msp/game/entity.h>
5 #include "rigidbody.h"
6 #include "collider.h"
7
8 struct PhysicalSetup
9 {
10         bool fixture = false;
11         RigidBodySetup body;
12         ColliderSetup collider;
13 };
14
15 class PhysicalEntity: public Msp::Game::Entity
16 {
17 public:
18         using Setup = PhysicalSetup;
19
20 protected:
21         Msp::Game::Owned<RigidBody> body;
22         Msp::Game::Owned<Collider> collider;
23
24 public:
25         PhysicalEntity(Msp::Game::Handle<Msp::Game::Entity>, const Setup &);
26
27         bool is_fixture() const { return !body; }
28         Msp::Game::Handle<RigidBody> get_body() const { return body; }
29         Msp::Game::Handle<Collider> get_collider() const { return collider; }
30 };
31
32 #endif