View difference between Paste ID: RurmLQ4Y and bxP41wzU
SHOW: | | - or go back to the newest paste.
1
	local function touchFunkx(event)
2
		local xDistance, yDistance = event.x - event.xStart, event.y - event.yStart
3
4
		if event.phase == "ended" then
5
			local distance = math.sqrt(xDistance * xDistance + yDistance * yDistance)
6-
			local angle = (math.atan2(yDistance, xDistance) * 180 / math.pi + 45) % 360
6+
			if distance >= 25 then
7-
			local dX, dY = 0, 0
7+
				local angle = (math.atan2(yDistance, xDistance) * 180 / math.pi + 45) % 360
8-
			if angle < 90 then
8+
				local dX, dY = 0, 0
9-
				dX = 1
9+
				if angle < 90 then
10-
			elseif angle < 180 then
10+
					dX = 1
11-
				dY = 1
11+
				elseif angle < 180 then
12-
			elseif angle < 270 then
12+
					dY = 1
13-
				dX = -1
13+
				elseif angle < 270 then
14-
			else
14+
					dX = -1
15-
				dY = -1
15+
				else
16
					dY = -1
17
				end
18
				hero.i, hero.j = move(gameMap, hero.i, hero.j, dX, dY)
19
			end
20
		end
21
	end