]> Untitled Git - lightcycles-love.git/blobdiff - scene.lua
Increased player speed
[lightcycles-love.git] / scene.lua
index 213d34ad9c668f8c44b2fe8f383a84d6662b11c2..4d159934fb037fe753d419f3b53e2986352d3687 100644 (file)
--- a/scene.lua
+++ b/scene.lua
@@ -5,6 +5,7 @@ require 'player'
 
 
 scene = {}
+scene.debug = false
 scene.paused = false
 scene.width = love.graphics.getWidth()
 scene.height = love.graphics.getHeight()
@@ -25,12 +26,21 @@ function scene:drawGrid()
     love.graphics.setBackgroundColor(self.grid.bgcolor)
     love.graphics.setColor(self.grid.linecolor)
 
+    love.graphics.setLineWidth(2)
     for x=0,self.width,self.grid.delta do
         love.graphics.line(x, 0, x, self.height)
     end
     for y=0,self.height,self.grid.delta do
         love.graphics.line(0, y, self.width, y)
     end
+
+    love.graphics.setLineWidth(0.5)
+    for x=0,self.width,self.grid.delta/2 do
+        love.graphics.line(x, 0, x, self.height)
+    end
+    for y=0,self.height,self.grid.delta/2 do
+        love.graphics.line(0, y, self.width, y)
+    end
 end
 
 function scene:drawPlayers()
@@ -44,7 +54,7 @@ function scene:draw()
     self:drawPlayers()
 
     -- draw intersection if it's there
-    if self.intersection then
+    if self.debug and self.intersection then
         love.graphics.setColor(0, 255, 0)
         love.graphics.line(self.intersection.a)
         love.graphics.setColor(0, 0, 255)
@@ -129,6 +139,16 @@ function scene:handleCollisions()
     for _,player in pairs(self.players) do
         local v1 = player.path.vector
         local v2 = player.path.prev.vector
+
+        -- outside boundary
+        if v1.x < 0 or v1.x > love.graphics.getWidth()
+        or v1.y < 0 or v1.y > love.graphics.getHeight()
+        then
+            love.event.push('collision', tostring(player))
+            break
+        end
+
+        -- inside boundary
         for _,player2 in pairs(self.players) do
             if doesLineIntersectPlayerPaths(player2.path, v1, v2) then
                 love.event.push('collision', tostring(player))