mirror of
https://github.com/tanema/light_world.lua.git
synced 2024-12-24 20:24:19 +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
|
if colorAberration == 0.0 then
|
||||||
colorAberration = 3.0
|
colorAberration = 3.0
|
||||||
end
|
end
|
||||||
|
elseif k == "f" then
|
||||||
|
lightWorld:remove(lightMouse)
|
||||||
|
elseif k == "g" then
|
||||||
|
lightWorld:remove(circleTest)
|
||||||
|
elseif k == "h" then
|
||||||
|
lightWorld:remove(rectangleTest)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
21
lib/init.lua
21
lib/init.lua
@ -417,4 +417,25 @@ function light_world:getLight(n)
|
|||||||
return self.lights[n]
|
return self.lights[n]
|
||||||
end
|
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
|
return light_world
|
||||||
|
Loading…
Reference in New Issue
Block a user