]> code.bitgloo.com Git - clyne/gamedev.git/commitdiff
better arrows
authorClyne Sullivan <tullivan99@gmail.com>
Fri, 24 Mar 2017 01:00:40 +0000 (21:00 -0400)
committerClyne Sullivan <tullivan99@gmail.com>
Fri, 24 Mar 2017 01:00:40 +0000 (21:00 -0400)
include/attack.hpp
src/attack.cpp
src/world.cpp

index 412694e9481a5c5944ba0e3cfd7d3dda6adf1c0d..027b93f8143540bdf7e9c93ca80a40bd04e6a052 100644 (file)
@@ -9,7 +9,8 @@
 
 enum class AttackType : char {
        ShortSlash,
-       LongSlash
+       LongSlash,
+       SmallBoom
 };
 
 struct AttackEvent {
index 4047b0a19b23d8ded0a49ca93de56440d822295b..550b8492e38d0a1aca61381d0bfa9befef3d9220 100644 (file)
@@ -49,6 +49,21 @@ void AttackSystem::update(entityx::EntityManager& en, entityx::EventManager& ev,
                                }
                        );
                        break;
+               case AttackType::SmallBoom:
+                       en.each<Position, Solid, Health>(
+                               [&a](entityx::Entity e, Position& pos, Solid& dim, Health& h) {
+                                       (void)e;
+                                       if (e.has_component<Player>())
+                                               return;
+
+                                       if (inrange(a.pos.x, pos.x, pos.x + dim.width, shortSlashLength)) {
+                                               h.health -= a.power;
+                                               game::engine.getSystem<ParticleSystem>()->addMultiple(15, ParticleType::SmallBlast,
+                                                       [&](){ return vec2(pos.x + dim.width / 2, pos.y + dim.height / 2); }, 300, 7);
+                                       }
+                               }
+                       );
+                       break;
                default:
                        break;
                }
index c41ab2a3625c1a81f449e5b1b4e05471295d3c11..353f4d9128d48914e558879034d83c940ca1b697 100644 (file)
@@ -1143,7 +1143,7 @@ void WorldSystem::detect(entityx::TimeDelta dt)
                                vel.y = 0;
                                if (e.has_component<Hit>()) {
                                        game::events.emit<AttackEvent>(vec2(loc.x, loc.y),
-                                               AttackType::ShortSlash, e.component<Hit>()->damage);
+                                               AttackType::SmallBoom, e.component<Hit>()->damage);
                                        e.destroy();
                                }
                                if (!vel.grounded) {