-- helper functions

local function lookAway(actor, pos)
	local y = actor.position.y - pos.y
	local x = actor.position.x - pos.x
	local rotation = math.atan(y, x)
	actor.rotation = math.deg(rotation)
end

local function distance(a, b)
	return math.sqrt((math.abs(a.x - b.x) ^ 2) + (math.abs(a.y - b.y) ^ 2))
end

function idle(actor, target)
	-- do nothing here for now
end

function patrol(actor, target)
	-- do nothing for now
end

function alert(actor, target)
	if target ~= nil then
		lookAway(actor, target.position)
		if distance(actor.position, target.position) < 250 then
			actor:moveForward()
		end
	end
end
