mirror of
https://github.com/tanema/light_world.lua.git
synced 2024-12-24 20:24:19 +00:00
commit
eaade0dd3c
2
conf.lua
2
conf.lua
@ -1,6 +1,6 @@
|
||||
function love.conf(t)
|
||||
t.identity = nil -- The name of the save directory (string)
|
||||
t.version = "0.10.0" -- The LÖVE version this game was made for (string)
|
||||
t.version = "11.1" -- The LÖVE version this game was made for (string)
|
||||
t.console = true -- Attach a console (boolean, Windows only)
|
||||
|
||||
t.window.title = "Untitled" -- The window title (string)
|
||||
|
@ -131,6 +131,7 @@ function light_world:drawShadows(l,t,w,h,s)
|
||||
love.graphics.setCanvas( self.shadowMap )
|
||||
love.graphics.clear()
|
||||
love.graphics.setCanvas()
|
||||
|
||||
util.drawto(self.shadowMap, l, t, s, function()
|
||||
--I dont know if it uses both or just calls both
|
||||
love.graphics.stencil(function()
|
||||
@ -154,6 +155,7 @@ function light_world:drawShadows(l,t,w,h,s)
|
||||
end
|
||||
end
|
||||
end)
|
||||
|
||||
-- draw scene for this light using normals and shadowmap
|
||||
self.shadowShader:send('lightColor', {light.red / 255.0, light.green / 255.0, light.blue / 255.0})
|
||||
self.shadowShader:send("lightPosition", {(light.x + l/s) * s, (light.y + t/s) * s, (light.z * 10) / 255.0})
|
||||
|
@ -48,7 +48,7 @@ function normal_map.fromHeightMap(heightMap, strength)
|
||||
end
|
||||
|
||||
function normal_map.generateFlat(img, mode)
|
||||
local imgData = img:getData()
|
||||
local imgData = love.image.newImageData(img:getWidth(), img:getHeight())
|
||||
local imgNormalData = love.image.newImageData(img:getWidth(), img:getHeight())
|
||||
local color
|
||||
|
||||
|
@ -27,7 +27,7 @@ local util = require(_PACKAGE..'/util')
|
||||
local post_shader = {}
|
||||
post_shader.__index = post_shader
|
||||
|
||||
local files = love.filesystem.getDirectoryItems(_PACKAGE.."/shaders/postshaders")
|
||||
local files = love.filesystem.getInfo(_PACKAGE .. "/shaders/postshaders")
|
||||
local shaders = {}
|
||||
|
||||
for i,v in ipairs(files) do
|
||||
|
@ -51,7 +51,7 @@ function util.drawto(canvas, x, y, scale, cb)
|
||||
local last_buffer = love.graphics.getCanvas()
|
||||
love.graphics.push()
|
||||
love.graphics.origin()
|
||||
love.graphics.setCanvas(canvas)
|
||||
love.graphics.setCanvas({canvas,stencil = true})
|
||||
love.graphics.translate(x, y)
|
||||
love.graphics.scale(scale)
|
||||
cb()
|
||||
|
28
main.lua
28
main.lua
@ -63,10 +63,10 @@ function exf.draw()
|
||||
lightWorld:draw(function()
|
||||
love.graphics.setBackgroundColor(0, 0, 0)
|
||||
|
||||
love.graphics.setColor(48, 156, 225)
|
||||
love.graphics.setColor(48/255, 156/255, 225/255)
|
||||
love.graphics.rectangle("fill", 0, 0, love.graphics.getWidth(), love.graphics.getHeight())
|
||||
|
||||
love.graphics.setColor(255, 255, 255, 191)
|
||||
love.graphics.setColor(1, 1, 1, 191/255)
|
||||
love.graphics.setFont(exf.bigfont)
|
||||
love.graphics.print("Examples:", 50, 50)
|
||||
|
||||
@ -75,7 +75,7 @@ function exf.draw()
|
||||
|
||||
exf.list:draw()
|
||||
|
||||
love.graphics.setColor(255, 255, 255)
|
||||
love.graphics.setColor(1, 1, 1)
|
||||
love.graphics.draw(exf.bigball, 800 - 128, 600 - 128, love.timer.getTime(), 1, 1, exf.bigball:getWidth() * 0.5, exf.bigball:getHeight() * 0.5)
|
||||
end)
|
||||
end
|
||||
@ -158,7 +158,7 @@ end
|
||||
|
||||
function exf.clear()
|
||||
love.graphics.setBackgroundColor(0,0,0)
|
||||
love.graphics.setColor(255, 255, 255)
|
||||
love.graphics.setColor(1, 1, 1)
|
||||
love.graphics.setLineWidth(1)
|
||||
love.graphics.setLineStyle("smooth")
|
||||
love.graphics.setBlendMode("alpha")
|
||||
@ -182,11 +182,11 @@ function exf.resume()
|
||||
|
||||
-- create light world
|
||||
lightWorld = LightWorld({
|
||||
ambient = {127, 127, 127}
|
||||
ambient = {127/255, 127/255, 127/255}
|
||||
})
|
||||
|
||||
-- create light
|
||||
lightMouse = lightWorld:newLight(0, 0, 255, 127, 63, 500)
|
||||
lightMouse = lightWorld:newLight(0, 0, 1, 127/255, 63/255, 500)
|
||||
lightMouse:setSmooth(2)
|
||||
|
||||
-- create shadow bodys
|
||||
@ -337,7 +337,7 @@ function List:draw()
|
||||
love.graphics.setLineStyle("rough")
|
||||
love.graphics.setFont(self.font)
|
||||
|
||||
love.graphics.setColor(48, 156, 225)
|
||||
love.graphics.setColor(48/255, 156/255, 1)
|
||||
|
||||
local mx, my = love.mouse.getPosition()
|
||||
|
||||
@ -357,17 +357,17 @@ function List:draw()
|
||||
local hover = inside(mx, my, x, y, w, h)
|
||||
|
||||
if hover then
|
||||
love.graphics.setColor(0, 0, 0, 127)
|
||||
love.graphics.setColor(0, 0, 0, 127/255)
|
||||
else
|
||||
love.graphics.setColor(0, 0, 0, 63)
|
||||
love.graphics.setColor(0, 0, 0, 63/255)
|
||||
end
|
||||
|
||||
love.graphics.rectangle("fill", x+1, y+i+1, w-3, h)
|
||||
|
||||
if hover then
|
||||
love.graphics.setColor(255, 255, 255)
|
||||
love.graphics.setColor(1, 1, 1, 1)
|
||||
else
|
||||
love.graphics.setColor(255, 255, 255, 127)
|
||||
love.graphics.setColor(1, 1, 1, 127/255)
|
||||
end
|
||||
|
||||
local e_id = string.sub(self.items[i], 1, 5)
|
||||
@ -385,15 +385,15 @@ function List:draw()
|
||||
local hover = inside(mx, my, x, y, w, h)
|
||||
|
||||
if hover or self.bar_lock then
|
||||
love.graphics.setColor(0, 0, 0, 127)
|
||||
love.graphics.setColor(0, 0, 0, 127/255)
|
||||
else
|
||||
love.graphics.setColor(0, 0, 0, 63)
|
||||
love.graphics.setColor(0, 0, 0, 63/255)
|
||||
end
|
||||
love.graphics.rectangle("fill", x, y, w, h)
|
||||
end
|
||||
|
||||
-- Border.
|
||||
love.graphics.setColor(0, 0, 0, 63)
|
||||
love.graphics.setColor(0, 0, 0, 63/255)
|
||||
love.graphics.rectangle("line", self.x+self.width, self.y, self.bar_width, self.height)
|
||||
love.graphics.rectangle("line", self.x, self.y, self.width, self.height)
|
||||
end
|
||||
|
Loading…
Reference in New Issue
Block a user