Merge branch 'master' of github.com:tanema/light_world.lua

This commit is contained in:
Tim Anema 2015-02-18 10:25:49 -05:00
commit 6314e1907b
2 changed files with 11 additions and 3 deletions

View File

@ -696,7 +696,7 @@ function body:drawPolyShadow(light)
for i = 1, #self.data, 2 do
local vertex = vector(self.data[i], self.data[i + 1])
local nextVertex = vector(self.data[(i + 2) % 8], self.data[(i + 2) % 8 + 1])
local nextVertex = vector(self.data[(i + 2) % #self.data], self.data[(i + 2) % #self.data + 1])
local startToEnd = nextVertex - vertex
if vector(startToEnd.y, -startToEnd.x) * (vertex - lightPosition) > 0 then
local point1 = (lh - (vertex * light.z))/height_diff

View File

@ -298,15 +298,23 @@ function light_world:newBody(type, ...)
return self.bodies[#self.bodies]
end
function light_world:is_body(target)
return target.type ~= nil
end
function light_world:is_light(target)
return target.angle ~= nil
end
function light_world:remove(to_kill)
if to_kill:is_a(Body) then
if self:is_body(to_kill) then
for i = 1, #self.bodies do
if self.bodies[i] == to_kill then
table.remove(self.bodies, i)
return true
end
end
elseif to_kill:is_a(Light) then
elseif self:is_light(to_kill) then
for i = 1, #self.lights do
if self.lights[i] == to_kill then
table.remove(self.lights, i)