-- wander_thunder.levelgen
variationVariable = 100 --bigger this, more noticeable movement
halfVariation = variationVariable / 2 

hp1 = levelgen:findObjectById(1)
hp2 = levelgen:findObjectById(2)
hp3 = levelgen:findObjectById(3)
hp4 = levelgen:findObjectById(4)

packArray = {hp1, hp2, hp3, hp4}

function onTick()
	for index, value in ipairs(packArray)
	do
		local pos = value:getPos()
		local roll1 = math.random(2)
		local roll2 = math.random(2)
		local odd1 = 1
		local odd2 = 1
		
		if(roll1 == 1) then
			odd1 = -1
		end
		if(roll2 == 1) then
			odd2 = -1
		end
		
		local x = math.random(variationVariable) * odd1 
		local y = math.random(variationVariable) * odd2
		
		local futurePos = pos + point.new(x, y)
		if(futurePos.x < 500 and futurePos.x > -500) then
			if(futurePos.y < 500 and futurePos.y > -500) then
				value:setGeom(futurePos)
			else
				value:setGeom(point.zero)
			end
		else
			value:setGeom(point.zero)
		end
	end
end

function main()
	subscribe(Event.Tick)
end