Im making a project and I need help,
How to make a function that will return true if the line from the position1 to position2 is obstacle free?
and
how to rotate image to position?
Thanks
if tile(x,y,"walkable") then
if tile(x,y,"obstacle")~=true then
imagepos(id,x,y,rot)		Changes position and rotation (0°-360°) of an image
function checkClearPath(start_x,start_y,destination_x,destination_y) 	rot = math.atan2(destination_y - start_y,desitnation_x - start_x ) -- finds rotation 	local tmpx = start_x; local tmpy = start_y -- these are used to store currect pos 	while(tmpx < destination_x and tmpy < destination_y) do --fixed it :) 		tmpx = tmpx + math.cos(rot) 		tmpy = tmpy + math.sin(rot) 		if not tile(tmpx,tmpy,"walkable") then 			return false 		end 	end 	return true end
function checkClearPath(start_x,start_y,destination_x,destination_y) 	rot = math.atan2(destination_y - start_y,desitnation_x - start_x ) -- finds rotation 	local tmpx = start_x; local tmpy = start_y -- these are used to store currect pos 	while(tmpx < destination_x and tmpy < destination_y) do --fixed it :) 		tmpx = tmpx + math.cos(rot) 		tmpy = tmpy + math.sin(rot) 		if not tile(tmpx,tmpy,"walkable") then 			return false 		end 	end 	return true end
function checkClearPath(start_x,start_y,destination_x,destination_y) 	rot = math.atan2(destination_y - start_y,destination_x - start_x ) -- finds rotation 	local tmpx = start_x; local tmpy = start_y -- these are used to store currect pos 	local xincrement = math.cos(rot); local yincrement = math.sin(rot) 	while(tmpx < destination_x and tmpy < destination_y) do --fixed it :) 		tmpx = tmpx + xincrement 		tmpy = tmpy + yincrement 		if not tile(tmpx,tmpy,"walkable") then 			return false 		end 	end 	return true end
local tmpx = start_x local tmpy = start_y
local tmpx = start_x 	local tmpy = start_y
local tmpx,tmpy = start_x,start_y
angle=Math.atan(y1-y2,x1-x2)
local xincrement = (blablabla) local yincrement = (blablabla)