my code currently looks like this
Code: Select all
drawHealth = function(self, health, delta)
local healthregion = health/100*327
self.health.liquid.position = (self.health.liquid.position + (75 * delta)) % 64
love.graphics.setCanvas({self.health.bg.canvas, stencil = true})
love.graphics.clear(0,0,0,0)
love.graphics.stencil(function()
love.graphics.setColor(1,1,1,1)
love.graphics.draw(self.health.bg.texture, 0,0)
end, "replace", 1)
love.graphics.setStencilTest("greater", 0)
love.graphics.setColor(1,0,0,1)
love.graphics.rectangle("fill", 0, 0, 64, healthregion)
love.graphics.setColor(1,1,1,1)
love.graphics.draw(self.health.liquid.texture, -80 + self.health.liquid.position, healthregion - 15)
love.graphics.setStencilTest()
love.graphics.setCanvas()
love.graphics.draw(self.health.bg.canvas, 34, 34)
love.graphics.draw(self.health.gold.texture, 4,32)
end,
i also tried to use a shader, but im horrible at shaders and so i didnt really understand what i was doing or what to do
can anyone help?