в общем я сделал новую либу в которой есть цветное освещение вот пример: Код require "jLight"
gr = love.graphics ms = love.mouse
function love.load() W, H = gr.getMode() jLight.Init(W, H) jLight.SetShadowColor(0, 0, 0) blue_light = jLight.AddPointSrc(0, 0, 200, {255, 128, 0})-- x, y, raius, {color} end
function love.update(dt) ms.x, ms.y = ms.getPosition() blue_light.x = ms.x blue_light.y = ms.y end
function love.draw() jLight.Clear() jLight.Begin(jLight.Src.Point) jLight.Wall(300, 300, 400, 300) jLight.Wall(300, 300, 300, 400) jLight.Wall(400, 400, 400, 300) jLight.Wall(400, 400, 300, 400) jLight.Sphere(500, 350, 25) jLight.End() jLight.Flush() end
вот ещё пример:
Код require "jLight"
gr = love.graphics ms = love.mouse
function love.load() W, H = gr.getMode() jLight.Init(W, H) jLight.SetShadowColor(0, 0, 0) red_light = jLight.AddDirectionalPointSrc(0, 0, 200, 0, 60, {255, 0, 0})-- x, y, raius, direction, width, {color} green_light = jLight.AddDirectionalPointSrc(0, 0, 200, 120, 60, {0, 128, 0})-- x, y, raius, direction, width, {color} blue_light = jLight.AddDirectionalPointSrc(0, 0, 200, 0, 60, {0, 0, 255})-- x, y, raius, direction, width, {color} end
function love.update(dt) ms.x, ms.y = ms.getPosition() red_light.x = ms.x red_light.y = ms.y green_light.x = ms.x green_light.y = ms.y blue_light.x = ms.x blue_light.y = ms.y red_light.d = red_light.d + 1 green_light.d = green_light.d + 1 blue_light.d = blue_light.d + 1 end
function love.draw() jLight.Clear() jLight.Begin(jLight.Src.DirectionalPoint) jLight.Wall(300, 300, 400, 300) jLight.Wall(300, 300, 300, 400) jLight.Wall(400, 400, 400, 300) jLight.Wall(400, 400, 300, 400) jLight.Sphere(500, 350, 25) jLight.End() jLight.Flush() end
ну и вот последний пример:
Код require "jLight"
gr = love.graphics ms = love.mouse
function love.load() W, H = gr.getMode() jLight.Init(W, H) jLight.SetShadowColor(0, 0, 0) torch_light = jLight.AddPointSrc(0, 0, 200, {255, 196, 128})-- x, y, raius, {color} sun_light = jLight.AddDirectionalSrc(math.rad(255), {128, 192, 255}) -- direction, {color} end
function love.update(dt) ms.x, ms.y = ms.getPosition() blue_light.x = ms.x blue_light.y = ms.y end
function love.draw() jLight.Clear()
jLight.Begin(jLight.Src.Point) _Terrain() jLight.End()
jLight.Begin(jLight.Src.Directional) _Terrain() jLight.End()
jLight.Flush() end
function _Terrain() -- section 1 jLight.Wall(300, 300, 400, 300) jLight.Wall(300, 400, 400, 400) -- section 2 jLight.Wall(400, 300, 500, 300) jLight.Wall(400, 400, 500, 400) -- section 3 -- jLight.Wall(500, 300, 600, 300) jLight.Wall(500, 400, 600, 400) -- section 4 jLight.Wall(500, 200, 600, 200) jLight.Wall(500, 200, 500, 300) jLight.Wall(600, 300, 600, 200) -- section 5 jLight.Wall(600, 300, 700, 300) jLight.Wall(600, 400, 700, 400) jLight.Wall(700, 300, 700, 400) end
в общем это всё.
|