diff --git a/src/levels.lua b/src/levels.lua index 2ddbf39..03610f0 100644 --- a/src/levels.lua +++ b/src/levels.lua @@ -1,4 +1,4 @@ -local LightWorld = require "lib.light_world" +local LightWorld = require "lib.LightWorld" require "lightWorldRectangleFix" local Object = {} diff --git a/src/lib/body.lua b/src/lib/LightWorld/body.lua similarity index 98% rename from src/lib/body.lua rename to src/lib/LightWorld/body.lua index 9cb52f5..fea2a87 100644 --- a/src/lib/body.lua +++ b/src/lib/LightWorld/body.lua @@ -109,30 +109,9 @@ function body:setPosition(x, y) 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 -function body:getX() - return self.x -end - --- get y position -function body:getY(y) - return self.y +function body:getPosition() + return self.x, self.y end -- get width diff --git a/src/lib/class.lua b/src/lib/LightWorld/class.lua similarity index 100% rename from src/lib/class.lua rename to src/lib/LightWorld/class.lua diff --git a/src/lib/light_world.lua b/src/lib/LightWorld/init.lua similarity index 93% rename from src/lib/light_world.lua rename to src/lib/LightWorld/init.lua index a804b11..1fb4cd5 100644 --- a/src/lib/light_world.lua +++ b/src/lib/LightWorld/init.lua @@ -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 SOFTWARE. ]] -local _PACKAGE = (...):match("^(.+)[%./][^%./]+") or "" -local class = require(_PACKAGE..'/class') -local Light = require(_PACKAGE..'/light') -local Body = require(_PACKAGE..'/body') -local util = require(_PACKAGE..'/util') -local normal_map = require(_PACKAGE..'/normal_map') -local PostShader = require(_PACKAGE..'/postshader') -require(_PACKAGE..'/postshader') +local _PACKAGE = string.gsub(...,"%.","/") or "" +if string.len(_PACKAGE) > 0 then + _PACKAGE = _PACKAGE .. "/" +end +local class = require(_PACKAGE..'class') +local Light = require(_PACKAGE..'light') +local Body = require(_PACKAGE..'body') +local util = require(_PACKAGE..'util') +local normal_map = require(_PACKAGE..'normal_map') +local PostShader = require(_PACKAGE..'postshader') +require(_PACKAGE..'postshader') local light_world = class() -light_world.blurv = love.graphics.newShader(_PACKAGE.."/shaders/blurv.glsl") -light_world.blurh = love.graphics.newShader(_PACKAGE.."/shaders/blurh.glsl") -light_world.refractionShader = love.graphics.newShader(_PACKAGE.."/shaders/refraction.glsl") -light_world.reflectionShader = love.graphics.newShader(_PACKAGE.."/shaders/reflection.glsl") +light_world.blurv = love.graphics.newShader(_PACKAGE.."shaders/blurv.glsl") +light_world.blurh = love.graphics.newShader(_PACKAGE.."shaders/blurh.glsl") +light_world.refractionShader = love.graphics.newShader(_PACKAGE.."shaders/refraction.glsl") +light_world.reflectionShader = love.graphics.newShader(_PACKAGE.."shaders/reflection.glsl") function light_world:init(options) self.lights = {} @@ -43,7 +46,6 @@ function light_world:init(options) self.post_shader = PostShader() self.ambient = {0, 0, 0} - self.normalInvert = false self.refractionStrength = 8.0 self.reflectionStrength = 16.0 @@ -51,6 +53,7 @@ function light_world:init(options) self.blur = 2.0 self.glowBlur = 1.0 + self.glowTimer = 0.0 self.glowDown = false @@ -275,6 +278,11 @@ function light_world:newLight(x, y, red, green, blue, range) return self.lights[#self.lights] end +function light_world:clear() + light_world:clearLights() + light_world:clearBodys() +end + -- clear lights function light_world:clearLights() self.lights = {} @@ -302,26 +310,6 @@ function light_world:setAmbientColor(red, green, blue) self.ambient = {red, green, blue} 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 function light_world:setBlur(blur) self.blur = blur diff --git a/src/lib/light.lua b/src/lib/LightWorld/light.lua similarity index 96% rename from src/lib/light.lua rename to src/lib/LightWorld/light.lua index 2afe867..f5db6c8 100644 --- a/src/lib/light.lua +++ b/src/lib/LightWorld/light.lua @@ -46,27 +46,8 @@ function light:setPosition(x, y, z) end -- get x -function light:getX() - return self.x -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 +function light:getPosition() + return self.x, self.y end -- set color diff --git a/src/lib/normal_map.lua b/src/lib/LightWorld/normal_map.lua similarity index 100% rename from src/lib/normal_map.lua rename to src/lib/LightWorld/normal_map.lua diff --git a/src/lib/postshader.lua b/src/lib/LightWorld/postshader.lua similarity index 100% rename from src/lib/postshader.lua rename to src/lib/LightWorld/postshader.lua diff --git a/src/lib/shaders/blurh.glsl b/src/lib/LightWorld/shaders/blurh.glsl similarity index 100% rename from src/lib/shaders/blurh.glsl rename to src/lib/LightWorld/shaders/blurh.glsl diff --git a/src/lib/shaders/blurv.glsl b/src/lib/LightWorld/shaders/blurv.glsl similarity index 100% rename from src/lib/shaders/blurv.glsl rename to src/lib/LightWorld/shaders/blurv.glsl diff --git a/src/lib/shaders/glow.glsl b/src/lib/LightWorld/shaders/glow.glsl similarity index 100% rename from src/lib/shaders/glow.glsl rename to src/lib/LightWorld/shaders/glow.glsl diff --git a/src/lib/shaders/material.glsl b/src/lib/LightWorld/shaders/material.glsl similarity index 100% rename from src/lib/shaders/material.glsl rename to src/lib/LightWorld/shaders/material.glsl diff --git a/src/lib/shaders/normal.glsl b/src/lib/LightWorld/shaders/normal.glsl similarity index 100% rename from src/lib/shaders/normal.glsl rename to src/lib/LightWorld/shaders/normal.glsl diff --git a/src/lib/shaders/normal_invert.glsl b/src/lib/LightWorld/shaders/normal_invert.glsl similarity index 100% rename from src/lib/shaders/normal_invert.glsl rename to src/lib/LightWorld/shaders/normal_invert.glsl diff --git a/src/lib/shaders/poly_shadow.glsl b/src/lib/LightWorld/shaders/poly_shadow.glsl similarity index 100% rename from src/lib/shaders/poly_shadow.glsl rename to src/lib/LightWorld/shaders/poly_shadow.glsl diff --git a/src/lib/shaders/postshaders/black_and_white.glsl b/src/lib/LightWorld/shaders/postshaders/black_and_white.glsl similarity index 100% rename from src/lib/shaders/postshaders/black_and_white.glsl rename to src/lib/LightWorld/shaders/postshaders/black_and_white.glsl diff --git a/src/lib/shaders/postshaders/chromatic_aberration.glsl b/src/lib/LightWorld/shaders/postshaders/chromatic_aberration.glsl similarity index 100% rename from src/lib/shaders/postshaders/chromatic_aberration.glsl rename to src/lib/LightWorld/shaders/postshaders/chromatic_aberration.glsl diff --git a/src/lib/shaders/postshaders/contrast.glsl b/src/lib/LightWorld/shaders/postshaders/contrast.glsl similarity index 100% rename from src/lib/shaders/postshaders/contrast.glsl rename to src/lib/LightWorld/shaders/postshaders/contrast.glsl diff --git a/src/lib/shaders/postshaders/curvature.glsl b/src/lib/LightWorld/shaders/postshaders/curvature.glsl similarity index 100% rename from src/lib/shaders/postshaders/curvature.glsl rename to src/lib/LightWorld/shaders/postshaders/curvature.glsl diff --git a/src/lib/shaders/postshaders/edges.glsl b/src/lib/LightWorld/shaders/postshaders/edges.glsl similarity index 100% rename from src/lib/shaders/postshaders/edges.glsl rename to src/lib/LightWorld/shaders/postshaders/edges.glsl diff --git a/src/lib/shaders/postshaders/four_colors.glsl b/src/lib/LightWorld/shaders/postshaders/four_colors.glsl similarity index 100% rename from src/lib/shaders/postshaders/four_colors.glsl rename to src/lib/LightWorld/shaders/postshaders/four_colors.glsl diff --git a/src/lib/shaders/postshaders/hdr_tv.glsl b/src/lib/LightWorld/shaders/postshaders/hdr_tv.glsl similarity index 100% rename from src/lib/shaders/postshaders/hdr_tv.glsl rename to src/lib/LightWorld/shaders/postshaders/hdr_tv.glsl diff --git a/src/lib/shaders/postshaders/monochrome.glsl b/src/lib/LightWorld/shaders/postshaders/monochrome.glsl similarity index 100% rename from src/lib/shaders/postshaders/monochrome.glsl rename to src/lib/LightWorld/shaders/postshaders/monochrome.glsl diff --git a/src/lib/shaders/postshaders/phosphor.glsl b/src/lib/LightWorld/shaders/postshaders/phosphor.glsl similarity index 100% rename from src/lib/shaders/postshaders/phosphor.glsl rename to src/lib/LightWorld/shaders/postshaders/phosphor.glsl diff --git a/src/lib/shaders/postshaders/phosphorish.glsl b/src/lib/LightWorld/shaders/postshaders/phosphorish.glsl similarity index 100% rename from src/lib/shaders/postshaders/phosphorish.glsl rename to src/lib/LightWorld/shaders/postshaders/phosphorish.glsl diff --git a/src/lib/shaders/postshaders/pip.glsl b/src/lib/LightWorld/shaders/postshaders/pip.glsl similarity index 100% rename from src/lib/shaders/postshaders/pip.glsl rename to src/lib/LightWorld/shaders/postshaders/pip.glsl diff --git a/src/lib/shaders/postshaders/pixellate.glsl b/src/lib/LightWorld/shaders/postshaders/pixellate.glsl similarity index 100% rename from src/lib/shaders/postshaders/pixellate.glsl rename to src/lib/LightWorld/shaders/postshaders/pixellate.glsl diff --git a/src/lib/shaders/postshaders/radialblur.glsl b/src/lib/LightWorld/shaders/postshaders/radialblur.glsl similarity index 100% rename from src/lib/shaders/postshaders/radialblur.glsl rename to src/lib/LightWorld/shaders/postshaders/radialblur.glsl diff --git a/src/lib/shaders/postshaders/scanlines.glsl b/src/lib/LightWorld/shaders/postshaders/scanlines.glsl similarity index 100% rename from src/lib/shaders/postshaders/scanlines.glsl rename to src/lib/LightWorld/shaders/postshaders/scanlines.glsl diff --git a/src/lib/shaders/postshaders/tilt_shift.glsl b/src/lib/LightWorld/shaders/postshaders/tilt_shift.glsl similarity index 100% rename from src/lib/shaders/postshaders/tilt_shift.glsl rename to src/lib/LightWorld/shaders/postshaders/tilt_shift.glsl diff --git a/src/lib/shaders/postshaders/waterpaint.glsl b/src/lib/LightWorld/shaders/postshaders/waterpaint.glsl similarity index 100% rename from src/lib/shaders/postshaders/waterpaint.glsl rename to src/lib/LightWorld/shaders/postshaders/waterpaint.glsl diff --git a/src/lib/shaders/reflection.glsl b/src/lib/LightWorld/shaders/reflection.glsl similarity index 100% rename from src/lib/shaders/reflection.glsl rename to src/lib/LightWorld/shaders/reflection.glsl diff --git a/src/lib/shaders/refraction.glsl b/src/lib/LightWorld/shaders/refraction.glsl similarity index 100% rename from src/lib/shaders/refraction.glsl rename to src/lib/LightWorld/shaders/refraction.glsl diff --git a/src/lib/stencils.lua b/src/lib/LightWorld/stencils.lua similarity index 100% rename from src/lib/stencils.lua rename to src/lib/LightWorld/stencils.lua diff --git a/src/lib/util.lua b/src/lib/LightWorld/util.lua similarity index 100% rename from src/lib/util.lua rename to src/lib/LightWorld/util.lua diff --git a/src/lib/vector.lua b/src/lib/LightWorld/vector.lua similarity index 100% rename from src/lib/vector.lua rename to src/lib/LightWorld/vector.lua