aboutsummaryrefslogtreecommitdiffstats
path: root/include/components
diff options
context:
space:
mode:
Diffstat (limited to 'include/components')
-rw-r--r--include/components/health.hpp8
-rw-r--r--include/components/sprite.hpp1
2 files changed, 9 insertions, 0 deletions
diff --git a/include/components/health.hpp b/include/components/health.hpp
index eacaaa5..f0b8e6b 100644
--- a/include/components/health.hpp
+++ b/include/components/health.hpp
@@ -3,6 +3,8 @@
#include "base.hpp"
+#include <SDL2/SDL_mixer.h>
+
/**
* @struct Health
* @brief Gives and entity health and stuff.
@@ -19,6 +21,7 @@ struct Health : public Component {
int health; /**< The current amount of health */
int maxHealth; /**< The maximum amount of health */
+ Mix_Chunk* ouch; /**< Sound made when attacked */
void fromXML(XMLElement* imp, XMLElement* def) final {
(void)imp;
@@ -27,6 +30,11 @@ struct Health : public Component {
if (def->QueryIntAttribute("value", &health) != XML_NO_ERROR)
health = 1;
maxHealth = health;
+ auto o = def->Attribute("ouch");
+ if (o != nullptr)
+ ouch = Mix_LoadWAV(o);
+ else
+ ouch = nullptr;
}
};
diff --git a/include/components/sprite.hpp b/include/components/sprite.hpp
index 0617620..33755b2 100644
--- a/include/components/sprite.hpp
+++ b/include/components/sprite.hpp
@@ -56,6 +56,7 @@ struct Sprite : public Component {
auto frames = developFrame(def);
if (!frames.empty())
sprite = frames.at(0);
+ faceLeft = false;
}
Frame sprite;