From 226bae411b83d851d5b30e0b0fa28a68bb8e7040 Mon Sep 17 00:00:00 2001 From: Clyne Sullivan Date: Wed, 14 Jun 2017 17:29:21 -0400 Subject: enemy flash red! --- include/components/all.hpp | 1 + src/attack.cpp | 6 ++++-- src/systems/dialog.cpp | 4 +--- xml/!town.xml | 2 +- 4 files changed, 7 insertions(+), 6 deletions(-) diff --git a/include/components/all.hpp b/include/components/all.hpp index dda8938..7c4e0d1 100644 --- a/include/components/all.hpp +++ b/include/components/all.hpp @@ -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" diff --git a/src/attack.cpp b/src/attack.cpp index f627631..2e5af99 100644 --- a/src/attack.cpp +++ b/src/attack.cpp @@ -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([&](entityx::Entity p, Hit& hit, Position& ppos) { bool die = false; en.each([&](entityx::Entity e, Health& health, Position& pos, Solid& dim) { if (!e.has_component() && 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(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(Color(255, 0, 0)); ParticleSystem::addMultiple(15, ParticleType::DownSlash, [&](){ return vec2(pos.x + dim.width / 2, pos.y + dim.height / 2); }, 300, 7); } diff --git a/src/systems/dialog.cpp b/src/systems/dialog.cpp index 0be0acb..f818760 100644 --- a/src/systems/dialog.cpp +++ b/src/systems/dialog.cpp @@ -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()) - e.remove(); - e.assign(Color(0, 255, 255)); + e.replace(Color(0, 255, 255)); if (!dialogRun.load()) { // copy entity, windows destroys the original after thread detach diff --git a/xml/!town.xml b/xml/!town.xml index 32f696a..219656f 100644 --- a/xml/!town.xml +++ b/xml/!town.xml @@ -17,7 +17,7 @@ - +