]> code.bitgloo.com Git - clyne/gamedev.git/commitdiff
drops are good
authorClyne Sullivan <tullivan99@gmail.com>
Sun, 30 Apr 2017 23:40:35 +0000 (19:40 -0400)
committerClyne Sullivan <tullivan99@gmail.com>
Sun, 30 Apr 2017 23:40:35 +0000 (19:40 -0400)
include/components/all.hpp
src/ui.cpp
src/world.cpp
xml/entities.xml

index ecba09f38d313a6c090989b45dfd3a7951476c9c..2fb3c8d083fda48f4622a160328b645e18e8d67b 100644 (file)
@@ -2,5 +2,6 @@
 #define COMPONENTS_ALL_HPP_
 
 #include "damage.hpp"
+#include "drop.hpp"
 
 #endif // COMPONENTS_ALL_HPP_
index e1e6eccc49d36ff472a389d063eef0bd110bf5e5..7cf768647959cd19214150aa47e48923bcb0d209 100644 (file)
@@ -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)
index 912a0c9a0d1c332882a0372c9409a0ae461c6837..73862ec2fd9734e3118085cc0dd147e696e26ac8 100644 (file)
@@ -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();
                }
index b2292c857a73569f8c59597e42a4a35ddda660ab..72431dc0c6e96fc65d9ac5ce7181b137051959db 100644 (file)
@@ -69,6 +69,9 @@
        <Wander />
        <!--<Aggro arena="arena.xml" />
        <Trigger />-->
+       <Drop>
+               <item name="Arrow" min="3" max="5" />
+       </Drop>
 </skirl>
 
 <structure>