]> git.tdb.fi Git - libs/game.git/blobdiff - examples/bassteroids/source/hittable.h
Make asteroids take damage when shot and eventually be destroyed
[libs/game.git] / examples / bassteroids / source / hittable.h
diff --git a/examples/bassteroids/source/hittable.h b/examples/bassteroids/source/hittable.h
new file mode 100644 (file)
index 0000000..b548a38
--- /dev/null
@@ -0,0 +1,34 @@
+#ifndef HITTABLE_H_
+#define HITTABLE_H_
+
+#include <msp/game/entity.h>
+#include "damagesource.h"
+#include "hitpoints.h"
+#include "physicalentity.h"
+
+struct HittableSetup
+{
+       bool immortal = false;
+       bool damaging = false;
+       HitPointsSetup hits;
+       DamageSourceSetup damage;
+};
+
+class Hittable: public PhysicalEntity
+{
+public:
+       using Setup = HittableSetup;
+
+private:
+       Msp::Game::Owned<HitPoints> hits;
+       Msp::Game::Owned<DamageSource> damage;
+
+public:
+       Hittable(Msp::Game::Handle<Msp::Game::Entity>, const Setup &, const PhysicalSetup &,
+               const Msp::Game::TransformValues & = Msp::Game::TransformValues());
+
+       Msp::Game::Handle<HitPoints> get_hitpoints() { return hits; }
+       Msp::Game::Handle<DamageSource> get_damage() { return damage; }
+};
+
+#endif