My thinking was that I might want TEXT_SPEED to be different (so I should declare it as a variable instead of a constant) depending on the gameState. So if I'm alive I want menu-stuff to show up slower or faster. Admittedly, it wasn't really thought through though as I just wanted my code to function to begin with.
Problems with a simple loop
Re: Problems with a simple loop
Re: Problems with a simple loop
The second part is correct. I'm not sure what you mean in the first part.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?
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
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.
Re: Problems with a simple loop
Hey man, thanks a ton for all of the information. Much appreciated as I finally got my text to work! Thank you again and have a good one!pgimeno wrote: ↑Wed Apr 15, 2020 1:47 pmThe second part is correct. I'm not sure what you mean in the first part.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?
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
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.
Who is online
Users browsing this forum: No registered users and 2 guests