In the default love.run, love.draw gets called after love.update. There's no difference if you put everything in love.draw or love.update except you can't draw stuff outside of love.draw. You can pass dt to love.draw if you want. It's good practice though, I believe, to separate your game logic from your drawing operations.
function love.run()
if love.load then love.load(arg) end
local dt = 0
-- Main loop time.
while true do
if love.timer then
love.timer.step()
dt = love.timer.getDelta()
end
if love.graphics then
love.graphics.clear()
if love.draw then love.draw(dt) end -- pass dt to love.draw
end
-- Process events.
if love.event then
for e,a,b,c in love.event.poll() do
if e == "q" then
if not love.quit or not love.quit() then
if love.audio then
love.audio.stop()
end
return
end
end
love.handlers[e](a,b,c)
end
end
if love.timer then love.timer.sleep(1) end
if love.graphics then love.graphics.present() end
end
end
Technically there isn't anything stopping you from calling 'calculation' in love.draw() however by default love.draw does not have access to delta time (dt). THe developers have split game logic and drawing to separate callbacks to keep things neat.
It's not very good practice to use love.draw() as an update loop.
EDIT: Also, unless you have a very good specific reason there's no need to modify love.run().
The reason that dt is given to love.update is because you're going to use it for moving sprites, and things like AI and collision detection use sprite locations.
Personally, I prefer making dt available for love.draw, so that animations can be done there. But, I stay with the spirit of the variable and pass it as a parameter to functions, rather than accessing a global variable. If I should need to not-animate, for some reason, I can pass a dt of 0.
Ensayia wrote:Just an FYI, you can call love.timer.getDelta() anywhere. This is how love.run() assigns it to dt.
Since things are designed so that little-to-no calculations are performed in the draw step, you shouldn't need to use getDelta very often since you can just pass/expose dt to your object/function. If you're referencing it a lot I guess you could trim a few calls by using dt instead of manually getting it from getDelta. References are cool.
Do you recognise when the world won't stop for you? Or when the days don't care what you've got to do? When the weight's too tough to lift up, what do you? Don't let them choose for you, that's on you.