Page 2 of 2
Re: Waiting.
Posted: Thu Apr 14, 2011 2:37 pm
by bartbes
miko wrote: you could use socket.sleep().
NOOOOOOOOO. It will do the same love.timer.sleep is, which is actually included by default too, and it will cause the entirety of the game to stop, no drawing, no updating, no events. So this is not a solution.
Re: Waiting.
Posted: Thu Apr 14, 2011 3:26 pm
by TheKraigose
I'm not sure if it helps or anything, because I'm not knowing the specifics of exactly what you are trying to accomplish.
However, when it comes to waiting... one thing I notice is I'm able to do a countdown clock method.
This is a simple example from my own game:
Code: Select all
-- in player.lua
pauseCooldown = 60 -- so the pause button actually works, we wait a while to make sure of this
-- many code and functions later...
-- in input.lua
function checkPauseKey()
if love.keyboard.isDown("p") and pauseCooldown >= 60 then -- check if we can "press 'p'" again
if isPaused == false then
isPaused = true -- this flag stops the main game rendering and logic
else
isPaused = false -- this flag unfreezes game rendering and logic
end
pauseCooldown = 0 -- set the cooldown to 0
end
if pauseCooldown < 60 then -- if not cooled down completely
pauseCooldown = pauseCooldown + 1 -- then we increment the cooldown timer up one tic
end
end
This might be tweaked a bit as it's a similar method I use to make enemies wait before shooting again. I just tweaked it for the user input to "wait".
Re: Waiting.
Posted: Thu Apr 14, 2011 8:28 pm
by Robin
Good example.
Code: Select all
if isPaused == false then
isPaused = true -- this flag stops the main game rendering and logic
else
isPaused = false -- this flag unfreezes game rendering and logic
end
How about:
?
Re: Waiting.
Posted: Thu Apr 14, 2011 9:26 pm
by TheKraigose
Robin wrote:Good example.
Code: Select all
if isPaused == false then
isPaused = true -- this flag stops the main game rendering and logic
else
isPaused = false -- this flag unfreezes game rendering and logic
end
How about:
?
Ah! I was not familiar with the
not keyword! Does it basically act like !varName does in C++?
Re: Waiting.
Posted: Thu Apr 14, 2011 9:36 pm
by bartbes
Yes.
Re: Waiting.
Posted: Thu Apr 14, 2011 10:32 pm
by BlackBulletIV
TheKraigose wrote:I was not familiar with the not keyword!
Oh dear, well you'll certainly need it. (Although you could use condition == false, but that gets ugly).