diff options
author | Clyne Sullivan <tullivan99@gmail.com> | 2017-03-14 18:19:06 -0400 |
---|---|---|
committer | Clyne Sullivan <tullivan99@gmail.com> | 2017-03-14 18:19:06 -0400 |
commit | ba651a82d585c181e9632fadba5bb4d683842d44 (patch) | |
tree | 8b2711866d497dfd471903c603e2f33bd4a41a5a /include | |
parent | a7d7d7e687cde01ed2d2ec2adb6ee5bfff8bbddc (diff) |
better slash, scale fixes
Diffstat (limited to 'include')
-rw-r--r-- | include/components.hpp | 21 | ||||
-rw-r--r-- | include/components/all.hpp | 6 | ||||
-rw-r--r-- | include/components/base.hpp | 29 | ||||
-rw-r--r-- | include/components/damage.hpp | 22 | ||||
-rw-r--r-- | include/particle.hpp | 9 | ||||
-rw-r--r-- | include/vector2.hpp | 5 |
6 files changed, 69 insertions, 23 deletions
diff --git a/include/components.hpp b/include/components.hpp index 2215a64..3f06867 100644 --- a/include/components.hpp +++ b/include/components.hpp @@ -22,25 +22,8 @@ #include <tinyxml2.h> using namespace tinyxml2; -/** - * @class Component - * @brief A base class for all components, insures all components have similar - * base functionalities. - */ -class Component : public entityx::Component<Component> { -public: - /** - * Constructs the component from the two given XML tags. - * - * Components can get information from two places: where the entity is defined - * (it's implementation, e.g. in town.xml) or from the tag's definition (e.g. entities.xml). - * The definition tag should be used for default values. - * - * @param imp tag for the implementation of the entity - * @param def tag for the definition of the component - */ - virtual void fromXML(XMLElement* imp, XMLElement* def) = 0; -}; +// TODO heyyy guys +#include <components/all.hpp> /** * @struct Position diff --git a/include/components/all.hpp b/include/components/all.hpp new file mode 100644 index 0000000..ecba09f --- /dev/null +++ b/include/components/all.hpp @@ -0,0 +1,6 @@ +#ifndef COMPONENTS_ALL_HPP_ +#define COMPONENTS_ALL_HPP_ + +#include "damage.hpp" + +#endif // COMPONENTS_ALL_HPP_ diff --git a/include/components/base.hpp b/include/components/base.hpp new file mode 100644 index 0000000..9139a75 --- /dev/null +++ b/include/components/base.hpp @@ -0,0 +1,29 @@ +#ifndef COMPONENTS_BASE_HPP_ +#define COMPONENTS_BASE_HPP_ + +#include <entityx/entityx.h> +#include <tinyxml2.h> + +using namespace tinyxml2; + +/** + * @class Component + * @brief A base class for all components, insures all components have similar + * base functionalities. + */ +class Component : public entityx::Component<Component> { +public: + /** + * Constructs the component from the two given XML tags. + * + * Components can get information from two places: where the entity is defined + * (it's implementation, e.g. in town.xml) or from the tag's definition (e.g. entities.xml). + * The definition tag should be used for default values. + * + * @param imp tag for the implementation of the entity + * @param def tag for the definition of the component + */ + virtual void fromXML(XMLElement* imp, XMLElement* def) = 0; +}; + +#endif // COMPONENTS_BASE_APP_ diff --git a/include/components/damage.hpp b/include/components/damage.hpp new file mode 100644 index 0000000..c257426 --- /dev/null +++ b/include/components/damage.hpp @@ -0,0 +1,22 @@ +#ifndef COMPONENTS_DAMAGE_HPP_ +#define COMPONENTS_DAMAGE_HPP_ + +#include "base.hpp" + +struct Damage : public Component { + Damage(int p = 0) + : pain(p) {} + Damage(XMLElement* imp, XMLElement* def) { + fromXML(imp, def); + } + + int pain; + + void fromXML(XMLElement* imp, XMLElement* def) final { + (void)imp; + if (def->QueryIntAttribute("value", &pain) != XML_NO_ERROR) + pain = 0; + } +}; + +#endif // COMPONENTS_DAMAGE_HPP_ diff --git a/include/particle.hpp b/include/particle.hpp index f49e055..822ac41 100644 --- a/include/particle.hpp +++ b/include/particle.hpp @@ -9,10 +9,11 @@ #include <entityx/entityx.h> enum class ParticleType : char { - Drop = 1, - Confetti = 2, - SmallBlast = 4, - SmallPoof = 8 + Drop, + Confetti, + SmallBlast, + SmallPoof, + DownSlash }; struct Particle { diff --git a/include/vector2.hpp b/include/vector2.hpp index 828654c..5671ccd 100644 --- a/include/vector2.hpp +++ b/include/vector2.hpp @@ -57,6 +57,11 @@ struct vector2 { return vector2<T>(x * n, y * n); } + vector2<T> operator*=(const T& n) { + x *= n, y *= n; + return *this; + } + // division vector2<T> operator/(const vector2<T>& v) const { return vector2<T>(x / v.x, y / v.y); |