2014-12-06 04:35:32 +00:00
|
|
|
local LightWorld = require "lib"
|
|
|
|
local sti = require 'examples.vendor.sti'
|
2021-11-10 01:15:14 +00:00
|
|
|
local lightWorld, map, image_normal, lightMouse
|
2014-12-06 04:35:32 +00:00
|
|
|
|
2021-11-10 01:15:14 +00:00
|
|
|
local function load()
|
2014-12-06 04:35:32 +00:00
|
|
|
-- create light world
|
2021-11-10 01:15:14 +00:00
|
|
|
lightWorld = LightWorld({ambient = {0.49, 0.49, 0.49}})
|
2016-04-26 13:23:11 +00:00
|
|
|
map = sti.new("examples/gfx/map.lua")
|
2014-12-06 04:35:32 +00:00
|
|
|
image_normal = love.graphics.newImage("examples/gfx/border_NRM.png")
|
|
|
|
-- create light
|
2021-11-10 01:15:14 +00:00
|
|
|
lightMouse = lightWorld:newLight(0, 0, 1, 0.49, 0.24, 300)
|
2014-12-06 04:35:32 +00:00
|
|
|
lightMouse:setGlowStrength(0.3)
|
2021-11-10 01:15:14 +00:00
|
|
|
-- create light blocking bodies for sections of the map
|
|
|
|
-- create walls
|
2014-12-06 04:35:32 +00:00
|
|
|
lightWorld:newRectangle(400, 32, 800, 64):setNormalMap(image_normal, 800, 64)
|
2021-11-08 21:36:38 +00:00
|
|
|
lightWorld:newRectangle(32, 272, 64, 416):setNormalMap(image_normal, 64, 416)
|
|
|
|
lightWorld:newRectangle(400, 464, 800, 32):setNormalMap(image_normal, 800, 32)
|
|
|
|
lightWorld:newRectangle(784, 272, 32, 416):setNormalMap(image_normal, 32, 416)
|
2021-11-10 01:15:14 +00:00
|
|
|
-- create blocks
|
2021-11-08 21:36:38 +00:00
|
|
|
lightWorld:newRectangle(224, 256, 128, 124):setNormalMap(image_normal, 128, 124)
|
|
|
|
lightWorld:newRectangle(592, 224, 224, 64):setNormalMap(image_normal, 224, 64)
|
2014-12-06 04:35:32 +00:00
|
|
|
end
|
|
|
|
|
2021-11-10 01:15:14 +00:00
|
|
|
local function update(dt)
|
2014-12-06 04:35:32 +00:00
|
|
|
love.window.setTitle("Light vs. Shadow Engine (FPS:" .. love.timer.getFPS() .. ")")
|
|
|
|
map:update(dt)
|
2014-12-21 18:14:46 +00:00
|
|
|
lightWorld:update(dt)
|
2021-11-10 01:15:14 +00:00
|
|
|
lightMouse:setPosition(love.mouse.getX(), love.mouse.getY())
|
2014-12-06 04:35:32 +00:00
|
|
|
end
|
|
|
|
|
2021-11-10 01:15:14 +00:00
|
|
|
local function draw()
|
|
|
|
love.graphics.setBackgroundColor(1, 1, 1)
|
|
|
|
lightWorld:draw(function()
|
|
|
|
map:draw()
|
|
|
|
end)
|
2014-12-06 04:35:32 +00:00
|
|
|
end
|
|
|
|
|
2021-11-10 01:15:14 +00:00
|
|
|
return {
|
|
|
|
load = load,
|
|
|
|
mousepressed = mousepressed,
|
|
|
|
update = update,
|
|
|
|
draw = draw,
|
|
|
|
}
|