Log In  


Hi everyone!

I am building a small pong clone and I would like the game to pause for 2 or 3 seconds whenever a player is scoring.

I saw that there are out there timer class but, since it was not easy for me to implement that, I wanted to ask if there is a simpler way to achieve this result.

Thanks!



timer=0
is_happening=false
SOME_LIMIT=60 -- 30 = 1 second with _update() running at 30FPS.
function _update()
 timer+=1
 if timer>=SOME_LIMIT and not is_happening then
  -- After two seconds, do something.
  do_something()
  is_happening=true
  timer=0
 end
end

Is this the sort of thing you were looking for in your other thread too?


Not really (I would like to use this solution to give the players a few seconds of pause after scoring, before starting the game again) but...
It could clearly work even there!

Tomorrow I'll try to implement it and let you know :)



[Please log in to post a comment]