mirror of
https://github.com/tanema/light_world.lua.git
synced 2024-12-24 20:24:19 +00:00
split the update method up into components, easier to understand
This commit is contained in:
parent
3502fe7d3e
commit
8115657d11
@ -261,7 +261,9 @@ end
|
||||
|
||||
-- draw shadow
|
||||
function light_world:drawShadow()
|
||||
if self.optionShadows and (self.isShadows or self.isLight) then
|
||||
if not self.optionShadows or not (self.isShadows or self.isLight) then
|
||||
return
|
||||
end
|
||||
love.graphics.setColor(255, 255, 255)
|
||||
if self.blur then
|
||||
self.last_buffer = love.graphics.getCanvas()
|
||||
@ -286,10 +288,12 @@ function light_world:drawShadow()
|
||||
love.graphics.setBlendMode("alpha")
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
-- draw shine
|
||||
function light_world:drawShine()
|
||||
if self.optionShadows and self.isShadows then
|
||||
if not self.optionShadows or not self.isShadows then
|
||||
return
|
||||
end
|
||||
love.graphics.setColor(255, 255, 255)
|
||||
if self.blur and false then
|
||||
self.last_buffer = love.graphics.getCanvas()
|
||||
@ -314,17 +318,19 @@ function light_world:drawShine()
|
||||
love.graphics.setBlendMode("alpha")
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
-- draw pixel shadow
|
||||
function light_world:drawPixelShadow()
|
||||
if self.optionPixelShadows and self.isPixelShadows then
|
||||
if not self.optionPixelShadows or not self.isPixelShadows then
|
||||
return
|
||||
end
|
||||
love.graphics.setColor(255, 255, 255)
|
||||
love.graphics.setBlendMode("multiplicative")
|
||||
love.graphics.setShader()
|
||||
love.graphics.draw(self.pixelShadow, self.translate_x, self.translate_y)
|
||||
love.graphics.setBlendMode("alpha")
|
||||
end
|
||||
end
|
||||
|
||||
-- draw material
|
||||
function light_world:drawMaterial()
|
||||
love.graphics.setShader(self.materialShader)
|
||||
@ -333,9 +339,13 @@ function light_world:drawMaterial()
|
||||
end
|
||||
love.graphics.setShader()
|
||||
end
|
||||
|
||||
-- draw glow
|
||||
function light_world:drawGlow()
|
||||
if self.optionGlow and self.isGlow then
|
||||
if not self.optionGlow or not self.isGlow then
|
||||
return
|
||||
end
|
||||
|
||||
love.graphics.setColor(255, 255, 255)
|
||||
if self.glowBlur == 0.0 then
|
||||
love.graphics.setBlendMode("additive")
|
||||
@ -360,10 +370,12 @@ function light_world:drawGlow()
|
||||
love.graphics.setBlendMode("alpha")
|
||||
end
|
||||
end
|
||||
end
|
||||
-- draw refraction
|
||||
function light_world:drawRefraction()
|
||||
if self.optionRefraction and self.isRefraction then
|
||||
if not self.optionRefraction or not self.isRefraction then
|
||||
return
|
||||
end
|
||||
|
||||
self.last_buffer = love.graphics.getCanvas()
|
||||
if self.last_buffer then
|
||||
love.graphics.setColor(255, 255, 255)
|
||||
@ -378,10 +390,13 @@ function light_world:drawRefraction()
|
||||
love.graphics.setShader()
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
-- draw reflection
|
||||
function light_world:drawReflection()
|
||||
if self.optionReflection and self.isReflection then
|
||||
if not self.optionReflection or not self.isReflection then
|
||||
return
|
||||
end
|
||||
|
||||
self.last_buffer = love.graphics.getCanvas()
|
||||
if self.last_buffer then
|
||||
love.graphics.setColor(255, 255, 255)
|
||||
@ -397,19 +412,21 @@ function light_world:drawReflection()
|
||||
love.graphics.setShader()
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
-- new light
|
||||
function light_world:newLight(x, y, red, green, blue, range)
|
||||
self.lights[#self.lights + 1] = Light(self, x, y, red, green, blue, range)
|
||||
self.isLight = true
|
||||
return self.lights[#self.lights]
|
||||
end
|
||||
|
||||
-- clear lights
|
||||
function light_world:clearLights()
|
||||
self.lights = {}
|
||||
self.isLight = false
|
||||
self.changed = true
|
||||
end
|
||||
|
||||
-- clear objects
|
||||
function light_world:clearBodys()
|
||||
self.body = {}
|
||||
@ -420,41 +437,50 @@ function light_world:clearBodys()
|
||||
self.isRefraction = false
|
||||
self.isReflection = false
|
||||
end
|
||||
|
||||
-- set offset
|
||||
function light_world:setTranslation(translateX, translateY)
|
||||
self.translate_x = translateX
|
||||
self.translate_y = translateY
|
||||
end
|
||||
|
||||
-- set ambient color
|
||||
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
|
||||
self.changed = true
|
||||
end
|
||||
|
||||
-- set blur
|
||||
function light_world:setShadowBlur(blur)
|
||||
self.blur = blur
|
||||
self.changed = true
|
||||
end
|
||||
|
||||
-- set buffer
|
||||
function light_world:setBuffer(buffer)
|
||||
if buffer == "render" then
|
||||
|
Loading…
Reference in New Issue
Block a user