diff options
-rw-r--r-- | include/components/all.hpp | 1 | ||||
-rw-r--r-- | src/ui.cpp | 6 | ||||
-rw-r--r-- | src/world.cpp | 20 | ||||
-rw-r--r-- | xml/entities.xml | 3 |
4 files changed, 29 insertions, 1 deletions
diff --git a/include/components/all.hpp b/include/components/all.hpp index ecba09f..2fb3c8d 100644 --- a/include/components/all.hpp +++ b/include/components/all.hpp @@ -2,5 +2,6 @@ #define COMPONENTS_ALL_HPP_ #include "damage.hpp" +#include "drop.hpp" #endif // COMPONENTS_ALL_HPP_ @@ -130,6 +130,9 @@ namespace ui { tickk = tickCount + tadv; ret += str[linc]; + if (!isspace(str[linc])) + Mix_PlayChannel(0, dialogClick, 0); + if (linc < size) { switch (str[++linc]) { case '!': @@ -868,6 +871,8 @@ void UISystem::dialogBox(const std::string& n, const std::string& s, ...) va_start(args, s); dialogText += ui::uisprintf(s.c_str(), args); va_end(args); + + ui::ret.clear(); } void UISystem::dialogAddOption(const std::string& o) @@ -878,6 +883,7 @@ void UISystem::dialogAddOption(const std::string& o) void UISystem::dialogImportant(const std::string& s) { importantText = s; + ui::ret.clear(); } void UISystem::waitForDialog(void) diff --git a/src/world.cpp b/src/world.cpp index 912a0c9..73862ec 100644 --- a/src/world.cpp +++ b/src/world.cpp @@ -89,6 +89,15 @@ constexpr const char* buildPaths[] = { ** Functions section ** --------------------------------------------------------------------------*/ +/*int generateString(const std::string& s) +{ + int mag = 0; + std::stringstream ss; + ss.str(s); + + ss >> mag >> ':'; +}*/ + void WorldSystem::generate(int width) { float geninc = 0; @@ -387,6 +396,8 @@ void WorldSystem::load(const std::string& file) entity.assign<Animate>(wxml, abcd); else if (tname == "Trigger") entity.assign<Trigger>(wxml, abcd); + else if (tname == "Drop") + entity.assign<Drop>(wxml, abcd); abcd = abcd->NextSiblingElement(); } @@ -675,7 +686,7 @@ void WorldSystem::render(void) static const float stardim = 24; GLfloat* star_coord = new GLfloat[stars.size() * 5 * 6 + 1]; - auto si = &star_coord; + auto si = star_coord; auto xcoord = offset.x * 0.9f; for (auto &s : stars) { @@ -1034,6 +1045,13 @@ void WorldSystem::detect(entityx::TimeDelta dt) game::entities.each<Health>( [](entityx::Entity e, Health& h) { if (h.health <= 0) { + if (e.has_component<Drop>()) { + for (auto& d : e.component<Drop>()->items) { + auto& pos = *e.component<Position>(); + InventorySystem::makeDrop(vec2(pos.x, pos.y), d.first, d.second); + } + } + e.kill(); //e.destroy(); } diff --git a/xml/entities.xml b/xml/entities.xml index b2292c8..72431dc 100644 --- a/xml/entities.xml +++ b/xml/entities.xml @@ -69,6 +69,9 @@ <Wander /> <!--<Aggro arena="arena.xml" /> <Trigger />--> + <Drop> + <item name="Arrow" min="3" max="5" /> + </Drop> </skirl> <structure> |