---------------------------
The code below produces extreme flickering. I'm looking to understand why, and how to fix it. This was something of an experiment to see if I could save on some draw calls by 'ignoring' a part of the screen after drawing what I need there once. I can see that it's "working", poked around in love.run() but nothing I did stopped the flickering.
Code: Select all
local heartbeat = 0
local heartbeatrise = true
local curColor = { 1, 1, 1, 1 }
function love.load()
love.graphics.setColor(0, 1, 0, 1)
love.graphics.rectangle("fill", 0, 0, 800, 600)
love.graphics.setScissor(0, 0, 400, 600)
end
function love.update(dt)
--Heartbeat timer
if (heartbeatrise) then
heartbeat = heartbeat + dt
if (heartbeat >= 1) then
heartbeat, heartbeatrise = 1, false
curColor = { 1, 1, 1, 1 }
end
else
heartbeat = heartbeat - dt
if (heartbeat <= 0) then
heartbeat, heartbeatrise = 0, true
curColor = { 1, 0, 0, 1 }
end
end
end
function love.draw()
love.graphics.setColor(curColor)
love.graphics.rectangle("fill", 0, 0, 400, 600)
end