From 9e540db7d6492168cadcafddbf145ffdd7b21981 Mon Sep 17 00:00:00 2001 From: Clyne Sullivan Date: Sun, 23 Jul 2017 10:47:10 -0400 Subject: source cleanup; beginning of custom attacks --- include/inventory.hpp | 39 +++++++++------------------------------ 1 file changed, 9 insertions(+), 30 deletions(-) (limited to 'include/inventory.hpp') diff --git a/include/inventory.hpp b/include/inventory.hpp index 1de22dc..ac87f38 100644 --- a/include/inventory.hpp +++ b/include/inventory.hpp @@ -16,6 +16,7 @@ #include using namespace tinyxml2; +#include #include #include @@ -33,36 +34,12 @@ struct Item { int cooldown; Item(void) - : value(0), stackSize(1) {} + : value(0), stackSize(1), cooldown(0) {} - /** - * Constructs an item from XML. - * @param the xml element () - */ - Item(XMLElement* e) { - name = e->StrAttribute("name"); - type = e->StrAttribute("type"); - - value = 0; - e->QueryIntAttribute("value", &value); - stackSize = 1; - e->QueryIntAttribute("maxStackSize", &stackSize); - - sprite = Texture(e->StrAttribute("sprite")); - - if (e->Attribute("sound") != nullptr) - sound = Mix_LoadWAV(e->Attribute("sound")); - else - sound = nullptr; - - cooldown = 250; - e->QueryIntAttribute("cooldown", &cooldown); - } - - ~Item(void) { + /*~Item(void) { if (sound != nullptr) Mix_FreeChunk(sound); - } + }*/ }; /** @@ -80,11 +57,12 @@ struct InventoryEntry { }; struct UseItemEvent { - Item* item; vec2 curs; + Item* item; + Attack* attack; - UseItemEvent(Item* i, vec2 c) - : item(i), curs(c) {} + UseItemEvent(vec2 c, Item* i, Attack* a = nullptr) + : curs(c), item(i), attack(a) {} }; /** @@ -100,6 +78,7 @@ private: constexpr static unsigned int rowSize = 8; static std::unordered_map itemList; + static std::unordered_map attackList; static std::vector items; static vec2 hotStart; -- cgit v1.2.3