mirror of
https://github.com/tanema/light_world.lua.git
synced 2024-12-24 20:24:19 +00:00
37 lines
809 B
Lua
37 lines
809 B
Lua
local stencils = {}
|
|
|
|
function stencils.shadow(geometry, bodies)
|
|
return function()
|
|
--cast shadows
|
|
for i = 1,#geometry do
|
|
if geometry[i].alpha == 1.0 then
|
|
love.graphics.polygon("fill", unpack(geometry[i]))
|
|
if geometry[i].circle then
|
|
love.graphics.circle("fill", unpack(geometry[i].circle))
|
|
end
|
|
end
|
|
end
|
|
-- underneath shadows
|
|
for i = 1, #bodies do
|
|
if not bodies[i].castsNoShadow then
|
|
bodies[i]:stencil()
|
|
end
|
|
end
|
|
end
|
|
end
|
|
|
|
function stencils.shine(bodies)
|
|
return function()
|
|
for i = 1, #bodies do
|
|
if bodies[i].shine and
|
|
(bodies[i].glowStrength == 0.0 or
|
|
(bodies[i].type == "image" and not bodies[i].normal))
|
|
then
|
|
bodies[i]:stencil()
|
|
end
|
|
end
|
|
end
|
|
end
|
|
|
|
return stencils
|