updated LightWorld
This commit is contained in:
@@ -1,4 +1,4 @@
|
|||||||
local LightWorld = require "lib.light_world"
|
local LightWorld = require "lib.LightWorld"
|
||||||
require "lightWorldRectangleFix"
|
require "lightWorldRectangleFix"
|
||||||
|
|
||||||
local Object = {}
|
local Object = {}
|
||||||
|
@@ -109,30 +109,9 @@ function body:setPosition(x, y)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
-- set x position
|
|
||||||
function body:setX(x)
|
|
||||||
if x ~= self.x then
|
|
||||||
self.x = x
|
|
||||||
self:refresh()
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
-- set y position
|
|
||||||
function body:setY(y)
|
|
||||||
if y ~= self.y then
|
|
||||||
self.y = y
|
|
||||||
self:refresh()
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
-- get x position
|
-- get x position
|
||||||
function body:getX()
|
function body:getPosition()
|
||||||
return self.x
|
return self.x, self.y
|
||||||
end
|
|
||||||
|
|
||||||
-- get y position
|
|
||||||
function body:getY(y)
|
|
||||||
return self.y
|
|
||||||
end
|
end
|
||||||
|
|
||||||
-- get width
|
-- get width
|
@@ -21,21 +21,24 @@ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|||||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||||
SOFTWARE.
|
SOFTWARE.
|
||||||
]]
|
]]
|
||||||
local _PACKAGE = (...):match("^(.+)[%./][^%./]+") or ""
|
local _PACKAGE = string.gsub(...,"%.","/") or ""
|
||||||
local class = require(_PACKAGE..'/class')
|
if string.len(_PACKAGE) > 0 then
|
||||||
local Light = require(_PACKAGE..'/light')
|
_PACKAGE = _PACKAGE .. "/"
|
||||||
local Body = require(_PACKAGE..'/body')
|
end
|
||||||
local util = require(_PACKAGE..'/util')
|
local class = require(_PACKAGE..'class')
|
||||||
local normal_map = require(_PACKAGE..'/normal_map')
|
local Light = require(_PACKAGE..'light')
|
||||||
local PostShader = require(_PACKAGE..'/postshader')
|
local Body = require(_PACKAGE..'body')
|
||||||
require(_PACKAGE..'/postshader')
|
local util = require(_PACKAGE..'util')
|
||||||
|
local normal_map = require(_PACKAGE..'normal_map')
|
||||||
|
local PostShader = require(_PACKAGE..'postshader')
|
||||||
|
require(_PACKAGE..'postshader')
|
||||||
|
|
||||||
local light_world = class()
|
local light_world = class()
|
||||||
|
|
||||||
light_world.blurv = love.graphics.newShader(_PACKAGE.."/shaders/blurv.glsl")
|
light_world.blurv = love.graphics.newShader(_PACKAGE.."shaders/blurv.glsl")
|
||||||
light_world.blurh = love.graphics.newShader(_PACKAGE.."/shaders/blurh.glsl")
|
light_world.blurh = love.graphics.newShader(_PACKAGE.."shaders/blurh.glsl")
|
||||||
light_world.refractionShader = love.graphics.newShader(_PACKAGE.."/shaders/refraction.glsl")
|
light_world.refractionShader = love.graphics.newShader(_PACKAGE.."shaders/refraction.glsl")
|
||||||
light_world.reflectionShader = love.graphics.newShader(_PACKAGE.."/shaders/reflection.glsl")
|
light_world.reflectionShader = love.graphics.newShader(_PACKAGE.."shaders/reflection.glsl")
|
||||||
|
|
||||||
function light_world:init(options)
|
function light_world:init(options)
|
||||||
self.lights = {}
|
self.lights = {}
|
||||||
@@ -43,7 +46,6 @@ function light_world:init(options)
|
|||||||
self.post_shader = PostShader()
|
self.post_shader = PostShader()
|
||||||
|
|
||||||
self.ambient = {0, 0, 0}
|
self.ambient = {0, 0, 0}
|
||||||
self.normalInvert = false
|
|
||||||
|
|
||||||
self.refractionStrength = 8.0
|
self.refractionStrength = 8.0
|
||||||
self.reflectionStrength = 16.0
|
self.reflectionStrength = 16.0
|
||||||
@@ -51,6 +53,7 @@ function light_world:init(options)
|
|||||||
|
|
||||||
self.blur = 2.0
|
self.blur = 2.0
|
||||||
self.glowBlur = 1.0
|
self.glowBlur = 1.0
|
||||||
|
|
||||||
self.glowTimer = 0.0
|
self.glowTimer = 0.0
|
||||||
self.glowDown = false
|
self.glowDown = false
|
||||||
|
|
||||||
@@ -275,6 +278,11 @@ function light_world:newLight(x, y, red, green, blue, range)
|
|||||||
return self.lights[#self.lights]
|
return self.lights[#self.lights]
|
||||||
end
|
end
|
||||||
|
|
||||||
|
function light_world:clear()
|
||||||
|
light_world:clearLights()
|
||||||
|
light_world:clearBodys()
|
||||||
|
end
|
||||||
|
|
||||||
-- clear lights
|
-- clear lights
|
||||||
function light_world:clearLights()
|
function light_world:clearLights()
|
||||||
self.lights = {}
|
self.lights = {}
|
||||||
@@ -302,26 +310,6 @@ function light_world:setAmbientColor(red, green, blue)
|
|||||||
self.ambient = {red, green, blue}
|
self.ambient = {red, green, blue}
|
||||||
end
|
end
|
||||||
|
|
||||||
-- set ambient red
|
|
||||||
function light_world:setAmbientRed(red)
|
|
||||||
self.ambient[1] = red
|
|
||||||
end
|
|
||||||
|
|
||||||
-- set ambient green
|
|
||||||
function light_world:setAmbientGreen(green)
|
|
||||||
self.ambient[2] = green
|
|
||||||
end
|
|
||||||
|
|
||||||
-- set ambient blue
|
|
||||||
function light_world:setAmbientBlue(blue)
|
|
||||||
self.ambient[3] = blue
|
|
||||||
end
|
|
||||||
|
|
||||||
-- set normal invert
|
|
||||||
function light_world:setNormalInvert(invert)
|
|
||||||
self.normalInvert = invert
|
|
||||||
end
|
|
||||||
|
|
||||||
-- set blur
|
-- set blur
|
||||||
function light_world:setBlur(blur)
|
function light_world:setBlur(blur)
|
||||||
self.blur = blur
|
self.blur = blur
|
@@ -46,27 +46,8 @@ function light:setPosition(x, y, z)
|
|||||||
end
|
end
|
||||||
|
|
||||||
-- get x
|
-- get x
|
||||||
function light:getX()
|
function light:getPosition()
|
||||||
return self.x
|
return self.x, self.y
|
||||||
end
|
|
||||||
|
|
||||||
-- get y
|
|
||||||
function light:getY()
|
|
||||||
return self.y
|
|
||||||
end
|
|
||||||
|
|
||||||
-- set x
|
|
||||||
function light:setX(x)
|
|
||||||
if x ~= self.x then
|
|
||||||
self.x = x
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
-- set y
|
|
||||||
function light:setY(y)
|
|
||||||
if y ~= self.y then
|
|
||||||
self.y = y
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
-- set color
|
-- set color
|
Reference in New Issue
Block a user