I want to start writing an application with alternating framebuffer, but already at the first step I am confused.
a example from the wiki (slightly expanded) don't work like expected:
Code: Select all
dtotal = 0 -- this keeps track of how much time has passed
function love.update(dt)
dtotal = dtotal + dt -- we add the time passed since the last update, probably a very small number like 0.01
if dtotal >= 1 then
print_a_frame()
dtotal = dtotal - 1 -- reduce our timer by a second, but don't discard the change... what if our framerate is 2/3 of a second?
end
end
print_a_frame = function()
function love.draw()
love.graphics.print( math.random(1,100), 10, 20)
end
end
An endless loop prints exactly every second a random number on the screen
What happened:
After an initial waiting period of one second (adjustiable by dtotal > 1) an endless loop prints as fast as it can (many times a second) a random number on the screen.
Can anyone explaine me that.
Greetings
ee