]> Untitled Git - lightcycles-love.git/blobdiff - scene.lua
Updated right angle message
[lightcycles-love.git] / scene.lua
index 404801f5704b14c39c95bda1f451648557332f01..83960e6bddf41b3e90c400fcc4bb349d6b18b2de 100644 (file)
--- a/scene.lua
+++ b/scene.lua
@@ -67,17 +67,27 @@ function doLinesIntersect(x1,y1, x2,y2, x3,y3, x4,y4)
     then
         -- if lines are parallel, no intersection!
     elseif x1 == x2 and y3 == y4 then
-        intersect =
-            x3 <= x1 and x1 <= x4
-            and
-            y1 <= y3 and y3 <= y2
+        intersect = (
+                x3 <= x1 and x1 <= x4
+                or
+                x4 <= x1 and x1 <= x3
+            ) and (
+                y1 <= y3 and y3 <= y2
+                or
+                y2 <= y3 and y3 <= y1
+            )
     elseif x3 == x4 and y1 == y2 then
-        intersect =
-            x1 <= x3 and x3 <= x2
-            and
-            y3 <= y1 and y1 <= y4
+        intersect = (
+                x1 <= x3 and x3 <= x2
+                or
+                x2 <= x3 and x3 <= x1
+            ) and (
+                y3 <= y1 and y1 <= y4
+                or
+                y4 <= y1 and y1 <= y3
+            )
     else
-        print('foo')
+        print('You should never see this message')
     end
 
     if intersect then