From 1fbc9b090201cf2df465f22f7e04330a73330bf3 Mon Sep 17 00:00:00 2001 From: Marcus Ihde Date: Fri, 7 Mar 2014 00:16:57 +0100 Subject: [PATCH] Add MIT License. --- license.txt | 21 +++++++++++++++++++++ light.lua | 4 ++++ main_example.lua | 40 ++++++++++++++++++++++++++++++++++++++++ 3 files changed, 65 insertions(+) create mode 100644 license.txt create mode 100644 main_example.lua diff --git a/license.txt b/license.txt new file mode 100644 index 0000000..06044b8 --- /dev/null +++ b/license.txt @@ -0,0 +1,21 @@ +The MIT License (MIT) + +Copyright (c) 2014 Marcus Ihde + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +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. \ No newline at end of file diff --git a/light.lua b/light.lua index a63dacd..6db3fc3 100644 --- a/light.lua +++ b/light.lua @@ -334,6 +334,10 @@ function love.light.newWorld() o.setPoints = function(n, ...) o.poly[n].data = {...} end + -- get polygon count + o.getObjectCount = function() + return #o.poly + #o.circle + end -- get circle count o.getCircleCount = function() return #o.circle diff --git a/main_example.lua b/main_example.lua new file mode 100644 index 0000000..80f10c3 --- /dev/null +++ b/main_example.lua @@ -0,0 +1,40 @@ +require "light" + +function love.load() + -- create light world + lightWorld = love.light.newWorld() + lightWorld.setAmbientColor(15, 15, 31) + + -- create light + lightMouse = lightWorld.newLight(0, 0, 255, 127, 63, 300) + lightMouse.setGlowStrength(0.3) + + -- create shadow bodys + circleTest = lightWorld.newCircle(256, 256, 32) + rectangleTest = lightWorld.newRectangle(512, 512, 64, 64) +end + +function love.update(dt) + love.window.setTitle("Light vs. Shadow Engine (FPS:" .. love.timer.getFPS() .. ")") + lightMouse.setPosition(love.mouse.getX(), love.mouse.getY()) +end + +function love.draw() + -- update lightmap (doesn't need deltatime) + lightWorld.update() + + -- draw background + love.graphics.setColor(255, 255, 255) + love.graphics.rectangle("fill", 0, 0, love.graphics.getWidth(), love.graphics.getHeight()) + + -- draw lightmap shadows + lightWorld.drawShadow() + + -- draw scene objects + love.graphics.setColor(63, 255, 127) + love.graphics.circle("fill", circleTest.getX(), circleTest.getY(), circleTest.getRadius()) + love.graphics.polygon("fill", rectangleTest.getPoints()) + + -- draw lightmap shine + lightWorld.drawShine() +end \ No newline at end of file