split the update method up into components, easier to understand

This commit is contained in:
Tim Anema 2014-09-27 12:59:51 -04:00
parent 3502fe7d3e
commit 8115657d11

View File

@ -261,7 +261,9 @@ end
-- draw shadow -- draw shadow
function light_world:drawShadow() 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) love.graphics.setColor(255, 255, 255)
if self.blur then if self.blur then
self.last_buffer = love.graphics.getCanvas() self.last_buffer = love.graphics.getCanvas()
@ -286,10 +288,12 @@ function light_world:drawShadow()
love.graphics.setBlendMode("alpha") love.graphics.setBlendMode("alpha")
end end
end end
end
-- draw shine -- draw shine
function light_world:drawShine() 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) love.graphics.setColor(255, 255, 255)
if self.blur and false then if self.blur and false then
self.last_buffer = love.graphics.getCanvas() self.last_buffer = love.graphics.getCanvas()
@ -314,17 +318,19 @@ function light_world:drawShine()
love.graphics.setBlendMode("alpha") love.graphics.setBlendMode("alpha")
end end
end end
end
-- draw pixel shadow -- draw pixel shadow
function light_world:drawPixelShadow() 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.setColor(255, 255, 255)
love.graphics.setBlendMode("multiplicative") love.graphics.setBlendMode("multiplicative")
love.graphics.setShader() love.graphics.setShader()
love.graphics.draw(self.pixelShadow, self.translate_x, self.translate_y) love.graphics.draw(self.pixelShadow, self.translate_x, self.translate_y)
love.graphics.setBlendMode("alpha") love.graphics.setBlendMode("alpha")
end end
end
-- draw material -- draw material
function light_world:drawMaterial() function light_world:drawMaterial()
love.graphics.setShader(self.materialShader) love.graphics.setShader(self.materialShader)
@ -333,9 +339,13 @@ function light_world:drawMaterial()
end end
love.graphics.setShader() love.graphics.setShader()
end end
-- draw glow -- draw glow
function light_world:drawGlow() 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) love.graphics.setColor(255, 255, 255)
if self.glowBlur == 0.0 then if self.glowBlur == 0.0 then
love.graphics.setBlendMode("additive") love.graphics.setBlendMode("additive")
@ -360,10 +370,12 @@ function light_world:drawGlow()
love.graphics.setBlendMode("alpha") love.graphics.setBlendMode("alpha")
end end
end end
end
-- draw refraction -- draw refraction
function light_world:drawRefraction() 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() self.last_buffer = love.graphics.getCanvas()
if self.last_buffer then if self.last_buffer then
love.graphics.setColor(255, 255, 255) love.graphics.setColor(255, 255, 255)
@ -378,10 +390,13 @@ function light_world:drawRefraction()
love.graphics.setShader() love.graphics.setShader()
end end
end end
end
-- draw reflection -- draw reflection
function light_world:drawReflection() 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() self.last_buffer = love.graphics.getCanvas()
if self.last_buffer then if self.last_buffer then
love.graphics.setColor(255, 255, 255) love.graphics.setColor(255, 255, 255)
@ -397,19 +412,21 @@ function light_world:drawReflection()
love.graphics.setShader() love.graphics.setShader()
end end
end end
end
-- new light -- new light
function light_world:newLight(x, y, red, green, blue, range) function light_world:newLight(x, y, red, green, blue, range)
self.lights[#self.lights + 1] = Light(self, x, y, red, green, blue, range) self.lights[#self.lights + 1] = Light(self, x, y, red, green, blue, range)
self.isLight = true self.isLight = true
return self.lights[#self.lights] return self.lights[#self.lights]
end end
-- clear lights -- clear lights
function light_world:clearLights() function light_world:clearLights()
self.lights = {} self.lights = {}
self.isLight = false self.isLight = false
self.changed = true self.changed = true
end end
-- clear objects -- clear objects
function light_world:clearBodys() function light_world:clearBodys()
self.body = {} self.body = {}
@ -420,41 +437,50 @@ function light_world:clearBodys()
self.isRefraction = false self.isRefraction = false
self.isReflection = false self.isReflection = false
end end
-- set offset -- set offset
function light_world:setTranslation(translateX, translateY) function light_world:setTranslation(translateX, translateY)
self.translate_x = translateX self.translate_x = translateX
self.translate_y = translateY self.translate_y = translateY
end end
-- set ambient color -- set ambient color
function light_world:setAmbientColor(red, green, blue) function light_world:setAmbientColor(red, green, blue)
self.ambient = {red, green, blue} self.ambient = {red, green, blue}
end end
-- set ambient red -- set ambient red
function light_world:setAmbientRed(red) function light_world:setAmbientRed(red)
self.ambient[1] = red self.ambient[1] = red
end end
-- set ambient green -- set ambient green
function light_world:setAmbientGreen(green) function light_world:setAmbientGreen(green)
self.ambient[2] = green self.ambient[2] = green
end end
-- set ambient blue -- set ambient blue
function light_world:setAmbientBlue(blue) function light_world:setAmbientBlue(blue)
self.ambient[3] = blue self.ambient[3] = blue
end end
-- set normal invert -- set normal invert
function light_world:setNormalInvert(invert) function light_world:setNormalInvert(invert)
self.normalInvert = invert self.normalInvert = invert
end end
-- set blur -- set blur
function light_world:setBlur(blur) function light_world:setBlur(blur)
self.blur = blur self.blur = blur
self.changed = true self.changed = true
end end
-- set blur -- set blur
function light_world:setShadowBlur(blur) function light_world:setShadowBlur(blur)
self.blur = blur self.blur = blur
self.changed = true self.changed = true
end end
-- set buffer -- set buffer
function light_world:setBuffer(buffer) function light_world:setBuffer(buffer)
if buffer == "render" then if buffer == "render" then