From 29876964587eda6e4d4bfc6543ea31efe983cf0a Mon Sep 17 00:00:00 2001 From: Clyne Sullivan Date: Mon, 13 Feb 2017 20:20:38 -0500 Subject: base component class; skirl fight plus --- src/components.cpp | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) (limited to 'src/components.cpp') diff --git a/src/components.cpp b/src/components.cpp index a66a1db..19ba0fb 100644 --- a/src/components.cpp +++ b/src/components.cpp @@ -22,10 +22,11 @@ static std::vector randomDialog (readFileA("assets/dialog_en-us")); void MovementSystem::update(entityx::EntityManager &en, entityx::EventManager &ev, entityx::TimeDelta dt) { - std::string arena; + bool fight = false; + entityx::Entity toFight; (void)ev; - en.each([&arena, dt](entityx::Entity entity, Position &position, Direction &direction) { + en.each([&](entityx::Entity entity, Position &position, Direction &direction) { position.x += direction.x * dt; position.y += direction.y * dt; @@ -52,11 +53,12 @@ void MovementSystem::update(entityx::EntityManager &en, entityx::EventManager &e if (entity.has_component()) { auto ppos = game::engine.getSystem()->getPosition(); if (ppos.x > position.x && ppos.x < position.x + entity.component()->width) { - auto& h = entity.component()->health; - if (h > 0) { - arena = entity.component()->arena; - h = 0; - } + //auto& h = entity.component()->health; + //if (h > 0) { + fight = true; + toFight = entity; + // h = 0; + //} } else direction.x = (ppos.x > position.x) ? .05 : -.05; } else if (entity.has_component()) { @@ -72,10 +74,10 @@ void MovementSystem::update(entityx::EntityManager &en, entityx::EventManager &e } }); - if (!arena.empty()) { + if (fight) { ui::toggleWhiteFast(); ui::waitForCover(); - game::engine.getSystem()->load(arena); + game::engine.getSystem()->fight(toFight); ui::toggleWhiteFast(); } } -- cgit v1.2.3