]> git.tdb.fi Git - libs/game.git/blob - examples/bassteroids/source/hitpoints.h
Use the setup generator to create setup structs
[libs/game.git] / examples / bassteroids / source / hitpoints.h
1 #ifndef HITPOINTS_H_
2 #define HITPOINTS_H_
3
4 #include <msp/game/component.h>
5 #include "setups.h"
6
7 struct HitPointsData
8 {
9         unsigned remaining_hits;
10 };
11
12 class HitPoints: public Msp::Game::BufferedComponent<HitPointsData>
13 {
14 public:
15         using Setup = HitPointsSetup;
16
17 private:
18         const Setup &setup;
19
20 public:
21         HitPoints(Msp::Game::Handle<Msp::Game::Entity>, const Setup &);
22
23         void take_damage(unsigned, unsigned);
24
25         bool is_alive() const { return read().remaining_hits; }
26 };
27
28 #endif