]> code.bitgloo.com Git - clyne/gamedev.git/commitdiff
enemy flash red!
authorClyne Sullivan <tullivan99@gmail.com>
Wed, 14 Jun 2017 21:29:21 +0000 (17:29 -0400)
committerClyne Sullivan <tullivan99@gmail.com>
Wed, 14 Jun 2017 21:29:21 +0000 (17:29 -0400)
include/components/all.hpp
src/attack.cpp
src/systems/dialog.cpp
xml/!town.xml

index dda89382660efb14d447070332a5419e75b86ddb..7c4e0d1c2930761803a9a8172c130fc3d08bcff1 100644 (file)
@@ -7,6 +7,7 @@
 #include "dialog.hpp"
 #include "direction.hpp"
 #include "drop.hpp"
+#include "flash.hpp"
 #include "grounded.hpp"
 #include "health.hpp"
 #include "hit.hpp"
index f62763186d70649f2076522571140f250d5f30ed..2e5af994d964d797fa3616dbe70cad3932f8b68c 100644 (file)
@@ -39,12 +39,13 @@ void AttackSystem::update(entityx::EntityManager& en, entityx::EventManager& ev,
        (void)ev;
        (void)dt;
 
-       // handle attacking entities
+       // handle painful entities (e.g. arrow)
        en.each<Hit, Position>([&](entityx::Entity p, Hit& hit, Position& ppos) {
                bool die = false;
                en.each<Health, Position, Solid>([&](entityx::Entity e, Health& health, Position& pos, Solid& dim) {
                        if (!e.has_component<Player>() && inrange(ppos.x, pos.x, pos.x + dim.width) && inrange(ppos.y, pos.y - 2, pos.y + dim.height)) {
                                health.health -= hit.damage;
+                               e.replace<Flash>(Color(255, 0, 0));
                                ParticleSystem::addMultiple(15, ParticleType::SmallBlast,
                                        [&](){ return vec2(pos.x + dim.width / 2, pos.y + dim.height / 2); }, 300, 7);
                                die = !hit.pierce;
@@ -56,7 +57,7 @@ void AttackSystem::update(entityx::EntityManager& en, entityx::EventManager& ev,
                        p.destroy();
        }); 
 
-       // handle emitted attacks
+       // handle emitted attacks (player's)
        for (const auto& a : attacks) {
                switch (a.type) {
                case AttackType::ShortSlash:
@@ -69,6 +70,7 @@ void AttackSystem::update(entityx::EntityManager& en, entityx::EventManager& ev,
                                        if (inrange(a.pos.x, pos.x, pos.x + dim.width, HLINES(shortSlashLength)) &&
                                                inrange(a.pos.y, pos.y, pos.y + dim.height)) {
                                                h.health -= a.power;
+                                               e.replace<Flash>(Color(255, 0, 0));
                                                ParticleSystem::addMultiple(15, ParticleType::DownSlash,
                                                        [&](){ return vec2(pos.x + dim.width / 2, pos.y + dim.height / 2); }, 300, 7);
                                        }
index 0be0acba0386c4ee29370151041ad75265024d2b..f81876096062ae45fa4db6083f1927df0544559e 100644 (file)
@@ -36,9 +36,7 @@ void DialogSystem::receive(const MouseClickEvent &mce)
                        if (((mce.position.x > pos.x) & (mce.position.x < pos.x + dim.width)) &&
                            ((mce.position.y > pos.y) & (mce.position.y < pos.y + dim.height))) {
 
-                       if (e.has_component<Flash>())
-                               e.remove<Flash>();
-                       e.assign<Flash>(Color(0, 255, 255));
+                       e.replace<Flash>(Color(0, 255, 255));
 
                        if (!dialogRun.load()) {
                                // copy entity, windows destroys the original after thread detach
index 32f696a0f3bd30ad7b40901372f14fcadac0067a..219656fff808042e9893cb9bcf76792d652541a6 100644 (file)
@@ -17,7 +17,7 @@
 
 <Dialog name="Bob">
     <text id="0" nextid="1">
-        <give name="Dank MayMay" count="10"/>
+        <give name="Wood Sword" count="1"/>
                <option name="Yes" />
                <option name="Yes daddy" />
                <option name="Ooooh boy yesss please" />