Code: Select all
local touches = love.touch.getTouches()
for i, id in ipairs(touches) do
local x, y = love.touch.getPosition(id)
if x < w / 2 then -- if player 1 touched her area
if x > 200 then -- if player 1 touched her movement area
p[1].xx = x -- set player 1's touchX (xx) to x
p[1].yy = y
else
if y < 200 then -- if player 1 touched first skill rectangle
if p[1].cd[1] <= 0 then -- if cooldown <= 0
p[1].cd[1] = 1 -- set cooldown to 1
end
elseif y < 400 then -- if touched second skill rectangle
if p[1].cd[2] <= 0 then
p[1].cd[2] = 2
end
elseif y < 600 then
if p[1].cd[3] <= 0 then
p[1].cd[3] = 4
end
elseif y < 800 then
if p[1].cd[4] <= 0 then
p[1].cd[4] = 8
end
end
end
else -- if player 2 touched her area
if x < w - 200 then -- if player 2 touched her movement area
p[2].xx = x
p[2].yy = y
else
if y > h - 200 then -- if player 2 touched her first skill rectangle
if p[2].cd[1] <= 0 then
p[2].cd[1] = 1
end
elseif y > h - 400 then
if p[2].cd[2] <= 0 then
p[2].cd[2] = 2
end
elseif y > h - 600 then
if p[2].cd[3] <= 0 then
p[2].cd[3] = 4
end
elseif y > h - 800 then
if p[2].cd[4] <= 0 then
p[2].cd[4] = 8
end
end
end
end