]> git.tdb.fi Git - libs/game.git/blob - examples/bassteroids/source/collider.h
Use the setup generator to create setup structs
[libs/game.git] / examples / bassteroids / source / collider.h
1 #ifndef COLLIDER_H_
2 #define COLLIDER_H_
3
4 #include <msp/game/component.h>
5 #include <msp/linal/vector.h>
6 #include "setups.h"
7
8 class Collider: public Msp::Game::Component
9 {
10 public:
11         using Setup = ColliderSetup;
12
13 private:
14         Setup setup;
15
16 public:
17         Collider(Msp::Game::Handle<Msp::Game::Entity>, const Setup &);
18
19         ColliderType get_type() const { return setup.type; }
20         float get_radius() const { return (setup.type==ColliderType::CIRCLE ? setup.radius : 0.0f); }
21         Msp::LinAl::Vector<float, 2> get_size() const { return (setup.type==ColliderType::BOX ? setup.size : Msp::LinAl::Vector<float, 2>()); }
22 };
23
24 #endif