Code: Select all
local light = {}
table.insert(light, {200, 200})
table.insert(light, {400,400})
local function myStencil()
local circleradius = 100
love.graphics.setColor(255, 255, 255, 235)
for i, xy in pairs(light) do
-- love.graphics.circle("fill", xy[1], xy[2], circleradius, 32)
gfx.draw(plight, xy[1], xy[2], 0, 1, 1,plight:getWidth()/2, plight:getHeight()/2)
gfx.draw(plight, player.x, player.y, 0, 1, 1,plight:getWidth()/2, plight:getHeight()/2)
--gfx.draw(plight, player.x+8, player.y, 0, 1, 1,plight:getWidth()/2, plight:getHeight()/2)
-- love.graphics.circle("fill", player.x+10, player.y, circleradius, 32)
end
end
function shadow_draw()
gfx.setColor( 255, 255, 255, 255 )
gfx.setInvertedStencil( myStencil )
gfx.setColor( 0, 0, 0, 235 )
gfx.rectangle( 'fill', 0, 0, 720, 480 )
gfx.setInvertedStencil()
gfx.setColor( 255, 255, 255, 235 )
gfx.setColor( 255, 255, 255, 235 )
gfx.draw(plight, player.x, player.y, 0, 1, 1,plight:getWidth()/2, plight:getHeight()/2)
for i, xy in pairs(light) do
gfx.setColor( 255, 255, 255, 235 )
gfx.draw(plight, xy[1], xy[2], 0, 1, 1,plight:getWidth()/2, plight:getHeight()/2)
love.graphics.setColor(255, 0, 0, 255)
love.graphics.circle("fill", xy[1], xy[2], 5, 32)
love.graphics.circle("fill", player.x+10, player.y, 5, 32)
love.graphics.setColor(255, 255, 255, 235)
end
end
plight is image with alpha.