aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/player.cpp1
-rw-r--r--src/world.cpp6
2 files changed, 7 insertions, 0 deletions
diff --git a/src/player.cpp b/src/player.cpp
index 2fb7c44..1908af4 100644
--- a/src/player.cpp
+++ b/src/player.cpp
@@ -238,6 +238,7 @@ void PlayerSystem::receive(const UseItemEvent& uie)
sprite->addSpriteSegment(SpriteData(tex.sprite), 0);
auto dim = HLINES(sprite->getSpriteSize());
e.assign<Solid>(dim.x, dim.y);
+ e.assign<Hit>(10);
}
}
diff --git a/src/world.cpp b/src/world.cpp
index 9a47576..c41ab2a 100644
--- a/src/world.cpp
+++ b/src/world.cpp
@@ -14,6 +14,7 @@ using namespace std::literals::chrono_literals;
using namespace tinyxml2;
// game headers
+#include <attack.hpp>
#include <common.hpp>
#include <components.hpp>
#include <debug.hpp>
@@ -1140,6 +1141,11 @@ void WorldSystem::detect(entityx::TimeDelta dt)
} else {
loc.y = data[line].groundHeight - 0.001f * dt;
vel.y = 0;
+ if (e.has_component<Hit>()) {
+ game::events.emit<AttackEvent>(vec2(loc.x, loc.y),
+ AttackType::ShortSlash, e.component<Hit>()->damage);
+ e.destroy();
+ }
if (!vel.grounded) {
vel.grounded = true;
game::engine.getSystem<ParticleSystem>()->addMultiple(20, ParticleType::SmallPoof,