]> code.bitgloo.com Git - clyne/gamedev.git/commitdiff
attack glow fix
authorClyne Sullivan <tullivan99@gmail.com>
Sat, 29 Jul 2017 22:45:41 +0000 (18:45 -0400)
committerClyne Sullivan <tullivan99@gmail.com>
Sat, 29 Jul 2017 22:45:41 +0000 (18:45 -0400)
src/attack.cpp

index f585a73473d123eff83738c63c277bb9bcc8f9d2..e4b2671aed3a3635a91e926dd998ef305d0d1649 100644 (file)
@@ -45,12 +45,11 @@ void AttackSystem::update(entityx::EntityManager& en, entityx::EventManager& ev,
                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;
-                               if (hit.effect.size() == 0)
-                                       e.replace<Flash>(Color(255, 0, 0));
-                               else
+                               e.replace<Flash>(Color(255, 0, 0));
+                               if (hit.effect.size() > 0)
                                        effects.emplace_back(vec2(ppos.x, ppos.y), hit.effect);
-                               ParticleSystem::addMultiple(15, ParticleType::SmallBlast,
-                                       [&](){ return vec2(pos.x + dim.width / 2, pos.y + dim.height / 2); }, 300, 7);
+                               //ParticleSystem::addMultiple(15, ParticleType::SmallBlast,
+                               //      [&](){ return vec2(pos.x + dim.width / 2, pos.y + dim.height / 2); }, 300, 7);
                                die = !hit.pierce;
                        } else if (WorldSystem::isAboveGround(vec2(ppos.x, ppos.y - 5)))
                                die = true;
@@ -74,10 +73,8 @@ void AttackSystem::update(entityx::EntityManager& en, entityx::EventManager& ev,
                                if (inrange(point.x, pos.x, pos.x + dim.width, HLINES(size.x)) &&
                                        inrange(point.y, pos.y, pos.y + dim.height, HLINES(size.y))) {
                                        h.health -= a.attack.power;
-
-                                       if (a.attack.effect.size() == 0)
-                                               e.replace<Flash>(Color(255, 0, 0));
-                                       else
+                                       e.replace<Flash>(Color(255, 0, 0));
+                                       if (a.attack.effect.size() > 0)
                                                effects.emplace_back(point, a.attack.effect);
                                        //ParticleSystem::addMultiple(15, ParticleType::DownSlash,
                                        //      [&](){ return vec2(pos.x + dim.width / 2, pos.y + dim.height / 2); }, 300, 7);