Lighting system
Posted: Sat Feb 12, 2011 10:53 pm
Oy! I'm trying to make a little lighting system for my project here... but i cant figure out a nice way to do it. What i want is to first draw the map, then have the "darkness" draw on top of the map. Each light is basically a open hole in the darkness. I do this to allow multiple light sources, which i need. Here's an example:
Here's the draw code for the example:
The reason why i can't use this, is because it's the map itself that is turning dark, and not a layer over it.
So my question is: How can i make a layer over the map that turns dark where there's no "light".
Here's the draw code for the example:
Code: Select all
local x, y = GetIsometricMouse()
love.graphics.setColor( 255, 255, 255, 255 )
love.graphics.draw( grad, x, y, 0, 1, 1, 128, 128 )
-- grad is an image of a round gradient, with white pixles in the middle.
love.graphics.setColor( 255, 255, 255, 255 )
love.graphics.draw( grad, 512, 256, 0, 1, 1, 128, 128 )
love.graphics.setBlendMode( "multiplicative" )
love.graphics.setColor( 255, 255, 255, 255 )
love.graphics.draw( rock, 0, 0, 0, 1, 1, 0, 0 )
-- rock is an image of some rocky texture. >>>( THE "MAP")<<<
love.graphics.setBlendMode( "alpha" )
So my question is: How can i make a layer over the map that turns dark where there's no "light".