Waiting.

General discussion about LÖVE, Lua, game development, puns, and unicorns.
User avatar
bartbes
Sex machine
Posts: 4946
Joined: Fri Aug 29, 2008 10:35 am
Location: The Netherlands
Contact:

Re: Waiting.

Post 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.
User avatar
TheKraigose
Prole
Posts: 9
Joined: Tue Apr 12, 2011 5:20 pm
Location: Somewhere that's Hi in the middle, Round at Both Ends!
Contact:

Re: Waiting.

Post 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".
User avatar
Robin
The Omniscient
Posts: 6506
Joined: Fri Feb 20, 2009 4:29 pm
Location: The Netherlands
Contact:

Re: Waiting.

Post 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:

Code: Select all

      isPaused = not isPaused
?
Help us help you: attach a .love.
User avatar
TheKraigose
Prole
Posts: 9
Joined: Tue Apr 12, 2011 5:20 pm
Location: Somewhere that's Hi in the middle, Round at Both Ends!
Contact:

Re: Waiting.

Post 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:

Code: Select all

      isPaused = not isPaused
?
Ah! I was not familiar with the not keyword! Does it basically act like !varName does in C++?
User avatar
bartbes
Sex machine
Posts: 4946
Joined: Fri Aug 29, 2008 10:35 am
Location: The Netherlands
Contact:

Re: Waiting.

Post by bartbes »

Yes.
User avatar
BlackBulletIV
Inner party member
Posts: 1261
Joined: Wed Dec 29, 2010 8:19 pm
Location: Queensland, Australia
Contact:

Re: Waiting.

Post 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).
Post Reply

Who is online

Users browsing this forum: Bing [Bot], Google [Bot], ThatBoiNavy and 8 guests