mirror of
https://github.com/tanema/light_world.lua.git
synced 2024-12-11 01:14:26 +00:00
added remove method to light world to facilitate removal of items
This commit is contained in:
parent
e74c0d8961
commit
3d4819cda4
@ -77,6 +77,12 @@ function love.keypressed(k)
|
||||
if colorAberration == 0.0 then
|
||||
colorAberration = 3.0
|
||||
end
|
||||
elseif k == "f" then
|
||||
lightWorld:remove(lightMouse)
|
||||
elseif k == "g" then
|
||||
lightWorld:remove(circleTest)
|
||||
elseif k == "h" then
|
||||
lightWorld:remove(rectangleTest)
|
||||
end
|
||||
end
|
||||
|
||||
|
21
lib/init.lua
21
lib/init.lua
@ -417,4 +417,25 @@ function light_world:getLight(n)
|
||||
return self.lights[n]
|
||||
end
|
||||
|
||||
function light_world:remove(to_kill)
|
||||
if to_kill:is_a(Body) then
|
||||
for i = 1, #self.body do
|
||||
if self.body[i] == to_kill then
|
||||
table.remove(self.body, i)
|
||||
return true
|
||||
end
|
||||
end
|
||||
elseif to_kill:is_a(Light) then
|
||||
for i = 1, #self.lights do
|
||||
if self.lights[i] == to_kill then
|
||||
table.remove(self.lights, i)
|
||||
return true
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
-- failed to find it
|
||||
return false
|
||||
end
|
||||
|
||||
return light_world
|
||||
|
Loading…
Reference in New Issue
Block a user