yoyohoho wrote: ↑Wed Apr 15, 2020 9:03 am
Awesome! Thank you so much. Does that also mean that once execution finishes the
render function it moves on to the
update function where it finishes the
if statement until
gameOver is >= 80 or does it only increment
gameOver once and then not again until execution goes through the code again the next frame?
The second part is correct. I'm not sure what you mean in the first part.
Anyway, Löve executes events in this order:
- First all input events (love.keypressed, love.mousemoved, etc.) presumably in the order they are generated.
- then the love.update event,
- then the love.draw event.
Then it repeats the sequence, 60 times a second (see (*) note above). The gory details are in
love.run.
This means that if your render function is called from love.draw, it will be executed after the update function, assuming the update function is called from love.update.
So, the sequence will be:
- Process inputs if any
- Increment y if it is < 80 (per the update function)
- Display (per the render function)
- Start again
This sounds correct for your intended effect. Note however that the first time that the update event is called, the variable dy does not have the value that the render function sets it to. I'm not sure why you are using that, but then I haven't dug into what your code is doing.
Anyway, here's a proof of concept of that very same method, but used in a stand-alone program, demonstrating that it works:
Code: Select all
local y = 0
local gameOver = -50
local dy = 40
love.graphics.setNewFont(50)
function love.update(dt)
if gameOver < 80 then
gameOver = gameOver + dy * dt
end
end
function love.draw()
love.graphics.print("Game Over", 0, gameOver)
end
yoyohoho wrote: ↑Wed Apr 15, 2020 9:03 am
I'm going to find a debug tool so I can go through the code step by step.
It's not easy to debug Löve programs. One problem is that you can't see the stuff that is being drawn until the frame ends. Another obstacle is that tracing through love.run is not possible because the debugger lacks the source code of boot.lua (which is embedded in the Löve executable, but the debugger doesn't know how to find it). So you may need to place breakpoints at events. Another obstacle is that while running the debugger, the Löve code gets horribly slowed down (someone mentioned ~1fps recently). But for the concept, it may help.