aboutsummaryrefslogtreecommitdiffstats
path: root/src/systems/movement.cpp
diff options
context:
space:
mode:
authorClyne Sullivan <tullivan99@gmail.com>2019-02-25 18:47:55 -0500
committerClyne Sullivan <tullivan99@gmail.com>2019-02-25 18:47:55 -0500
commitd7bae41fab5570bdac547a46463974adb4723f96 (patch)
tree37b0567300f2e3d0a74ceae5861272f4ff970558 /src/systems/movement.cpp
parent58774909a78f06b8de3cb60e2f010e8ceccbf3a6 (diff)
mem leak patches; world ground from image
Diffstat (limited to 'src/systems/movement.cpp')
-rw-r--r--src/systems/movement.cpp24
1 files changed, 11 insertions, 13 deletions
diff --git a/src/systems/movement.cpp b/src/systems/movement.cpp
index 642fa6a..b2c95c5 100644
--- a/src/systems/movement.cpp
+++ b/src/systems/movement.cpp
@@ -10,11 +10,21 @@
#include <thread>
-#include <attack.hpp>
#include <events.hpp>
#include <player.hpp>
#include <ui.hpp>
+LuaScript MovementSystem::hitPlayer;
+Attack MovementSystem::playerAttack;
+
+int MovementSystem::doAttack(lua_State* s)
+{
+ vec2 pos (lua_tonumber(s, 1), lua_tonumber(s, 2));
+ game::events.emit<AttackEvent>(AttackEvent(pos,
+ playerAttack, false));
+ return 0;
+}
+
void MovementSystem::update(entityx::EntityManager &en, entityx::EventManager &ev, entityx::TimeDelta dt)
{
//bool fight = false;
@@ -72,18 +82,6 @@ void MovementSystem::update(entityx::EntityManager &en, entityx::EventManager &e
}
}
- static auto doAttack = [](lua_State* s) -> int {
- vec2 pos (lua_tonumber(s, 1), lua_tonumber(s, 2));
- LuaScript script ("effect = function()\nflash(255,0,0)\ndamage(1)\nend\n\
- hit = function()\nxrange = 5\nend");
- AttackSystem::initLua(script);
- Attack attack = {vec2(), vec2(5, 5), vec2(), vec2(),
- script, TextureIterator()};
- game::events.emit<AttackEvent>(AttackEvent(pos,
- attack, false));
- return 0;
- };
-
// make the entity wander
// TODO initialX and range?
if (entity.has_component<Wander>()) {