diff options
Diffstat (limited to 'include')
-rw-r--r-- | include/common.hpp | 5 | ||||
-rw-r--r-- | include/inventory.hpp | 35 | ||||
-rw-r--r-- | include/player.hpp | 3 | ||||
-rw-r--r-- | include/texture.hpp | 4 | ||||
-rw-r--r-- | include/world.hpp | 7 |
5 files changed, 51 insertions, 3 deletions
diff --git a/include/common.hpp b/include/common.hpp index 0364b8b..d152bb7 100644 --- a/include/common.hpp +++ b/include/common.hpp @@ -99,6 +99,11 @@ struct vec2 { return vec2 (x + n, y + n); } + template<typename T> + const vec2 operator*(const T &n) { + return vec2 (x * n, y * n); + } + // std::swap can't work due to being packed inline void swapX(vec2 &v) { diff --git a/include/inventory.hpp b/include/inventory.hpp new file mode 100644 index 0000000..fa24de4 --- /dev/null +++ b/include/inventory.hpp @@ -0,0 +1,35 @@ +#ifndef INVENTORY_HPP_ +#define INVENTORY_HPP_ + +#include <entityx/entityx.h> + +#include <components.hpp> +#include <events.hpp> + +struct Item { + GLuint icon; +}; + +using InventoryEntry = std::pair<Item, unsigned int>; + +class InventorySystem : public entityx::System<InventorySystem>, public entityx::Receiver<InventorySystem> { +private: + entityx::Entity currentItemEntity; + + std::vector<InventoryEntry> items; + unsigned int maxItemCount; + +public: + InventorySystem(unsigned int mic = 1) + : maxItemCount(mic) {} + + void configure(entityx::EventManager &ev); + + void loadIcons(void); + + void update(entityx::EntityManager &en, entityx::EventManager &ev, entityx::TimeDelta dt) override; + + void receive(const KeyDownEvent &kde); +}; + +#endif // INVENTORY_HPP_ diff --git a/include/player.hpp b/include/player.hpp index 1caccc8..6bad917 100644 --- a/include/player.hpp +++ b/include/player.hpp @@ -4,6 +4,7 @@ #include <entityx/entityx.h> #include <events.hpp> +#include <common.hpp> constexpr const float PLAYER_SPEED_CONSTANT = 0.15f; @@ -29,6 +30,8 @@ public: inline void setPlayer(const entityx::Entity& e) { pid = e.id(); } + + vec2 getPosition(void) const; }; #endif // PLAYER_HPP_ diff --git a/include/texture.hpp b/include/texture.hpp index 7426a46..88dae65 100644 --- a/include/texture.hpp +++ b/include/texture.hpp @@ -51,11 +51,11 @@ private: return freeID; } id_t++; - } + } } public: uint64_t loadSprite(std::string s) { - uint64_t tex_e; + uint64_t tex_e = 0; try { tex_e = spritesLoc.at(s); } catch (const std::out_of_range& oor) { diff --git a/include/world.hpp b/include/world.hpp index 1f54292..58dfc2c 100644 --- a/include/world.hpp +++ b/include/world.hpp @@ -134,6 +134,8 @@ private: XMLDocument xmlDoc; + std::string currentXMLFile; + public: explicit WorldSystem(void); ~WorldSystem(void); @@ -156,13 +158,16 @@ public: inline const WorldWeather& getWeatherId(void) const { return weather; } + inline const std::string& getXMLFile(void) const + { return currentXMLFile; } + void setWeather(const std::string &s); void detect(entityx::TimeDelta dt); void goWorldLeft(Position& p); void goWorldRight(Position& p); - + // worlddata2 stuff WorldData2 worldData; |