aboutsummaryrefslogtreecommitdiffstats
path: root/include/systems/movement.hpp
blob: 745fa9b7a6c8520a713584dbebf9e64132e7a712 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
#ifndef SYSTEM_MOVEMENT_HPP_
#define SYSTEM_MOVEMENT_HPP_

#include <entityx/entityx.h>
#include <attack.hpp>

class MovementSystem : public entityx::System<MovementSystem> {
private:
	constexpr static const char *hitPlayerScript = "\
		effect = function()\n \
			flash(255, 0, 0)\n \
			damage(1)\n \
		end\n \
		hit = function()\n \
			xrange = 5\n \
		end";
	static LuaScript hitPlayer;
	static Attack playerAttack;

public:
	MovementSystem(void) {
		hitPlayer = LuaScript(hitPlayerScript);
		AttackSystem::initLua(hitPlayer);
		playerAttack = { vec2(), vec2(5, 5), vec2(), vec2(),
			hitPlayer, TextureIterator() };
	}

	void update(entityx::EntityManager &en, entityx::EventManager &ev, entityx::TimeDelta dt) override;

	static int doAttack(lua_State *);
};

#endif // SYSTEM_MOVEMENT_HPP_