more lights

This commit is contained in:
Tim Anema 2021-11-09 20:29:14 -05:00
parent fe2250b1df
commit a2f741ede4
No known key found for this signature in database
GPG Key ID: 222D82A25F3857A4

View File

@ -1,6 +1,8 @@
local LightWorld = require "lib" local LightWorld = require "lib"
local lightWorld, lightMouse local lightWorld, lightMouse
local image, image_normal, glow, circleTest, rectangleTest, imageTest, objectTest local image, image_normal, glow, circleTest, rectangleTest, imageTest, objectTest
local scanLight, floatLight
local lightDirection = 0.0
local box_locations = { local box_locations = {
{200, 200}, {200, 200},
@ -16,8 +18,16 @@ local function load()
-- create light world -- create light world
lightWorld = LightWorld({ambient = {0.21,0.21,0.21}}) lightWorld = LightWorld({ambient = {0.21,0.21,0.21}})
-- create light -- create light
lightMouse = lightWorld:newLight(0, 0, 255, 127, 63, 300) lightMouse = lightWorld:newLight(0, 0, 1, 0.49, 1, 300)
lightMouse:setGlowStrength(0.3) lightMouse:setGlowStrength(0.3)
scanLight = lightWorld:newLight(400, 550, 1, 1, 0.24, 400)
scanLight:setAngle(0.7)
scanLight:setDirection(3.4)
floatLight = lightWorld:newLight(100, 100, 0.49, 1, 1, 200)
floatLight:setGlowStrength(0.3)
-- create shadow bodys -- create shadow bodys
for i, v in ipairs(box_locations) do for i, v in ipairs(box_locations) do
imageTest = lightWorld:newImage(image, v[1], v[2]) imageTest = lightWorld:newImage(image, v[1], v[2])
@ -27,6 +37,10 @@ local function load()
end end
local function update(dt, x, y, scale) local function update(dt, x, y, scale)
floatLight:setPosition(math.sin(-1*lightDirection)*200+400, 100)
scanLight:setDirection(math.sin(lightDirection)+4.8)
lightDirection = lightDirection + dt
love.window.setTitle("Light vs. Shadow Engine (FPS:" .. love.timer.getFPS() .. ")") love.window.setTitle("Light vs. Shadow Engine (FPS:" .. love.timer.getFPS() .. ")")
x, y, scale = x or 0, y or 0, scale or 1 x, y, scale = x or 0, y or 0, scale or 1
lightMouse:setPosition((love.mouse.getX() - x)/scale, (love.mouse.getY() - y)/scale) lightMouse:setPosition((love.mouse.getX() - x)/scale, (love.mouse.getY() - y)/scale)