aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorClyne Sullivan <tullivan99@gmail.com>2017-06-14 17:29:21 -0400
committerClyne Sullivan <tullivan99@gmail.com>2017-06-14 17:29:21 -0400
commit226bae411b83d851d5b30e0b0fa28a68bb8e7040 (patch)
treefbe56ff6fa5b1841ebff6bc5ceda5511de7b3b8e
parent316df0931c66e43e69f21bda28c77b9bdb1e8bca (diff)
enemy flash red!
-rw-r--r--include/components/all.hpp1
-rw-r--r--src/attack.cpp6
-rw-r--r--src/systems/dialog.cpp4
-rw-r--r--xml/!town.xml2
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<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);
}
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<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
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 @@
<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" />