From: Clifton James Palmer Date: Sat, 8 Dec 2018 19:41:19 +0000 (-0600) Subject: Fixed collision conditions X-Git-Url: http://git.purplebirdman.com/lightcycles-love.git/commitdiff_plain/2a7294cc83f5986b50bbb824ecc3b429453cb173 Fixed collision conditions --- diff --git a/scene.lua b/scene.lua index f11fc3e..08b96de 100644 --- a/scene.lua +++ b/scene.lua @@ -60,10 +60,6 @@ function scene:updatePlayers(dt) end function doLinesIntersect(x1,y1, x2,y2, x3,y3, x4,y4) - scene.intersection = { - a = {x1,y1, x2,y2}, - b = {x3,y3, x4,y4}, - } if x1 == x2 and x3 == x4 or y1 == y2 and y3 == y4 then @@ -73,13 +69,21 @@ function doLinesIntersect(x1,y1, x2,y2, x3,y3, x4,y4) -- if lines are not parallel, they must intersect -- do segments overlap? if - x1 <= x3 and x3 <= x2 - and y1 <= y3 and y3 <= y2 - or - x3 <= x1 and x1 <= x4 - and y3 <= y1 and y1 <= y4 + ( + (x1 <= x3 and x3 <= x2 or x1 <= x4 and x4 <= x2) + or + (x3 <= x1 and x1 <= x4 or x3 <= x2 and x2 <= x4) + ) and ( + (y1 <= y3 and y3 <= y2 or y1 <= y4 and y4 <= y2) + or + (y3 <= y1 and y1 <= y4 or y3 <= y2 and y2 <= y4) + ) then scene.paused = true + scene.intersection = { + a = {x1,y1, x2,y2}, + b = {x3,y3, x4,y4}, + } return true end end