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!

P#38676 2017-03-24 09:06 ( Edited 2017-03-24 23:17)

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
P#38677 2017-03-24 09:42 ( Edited 2017-03-24 13:52)

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

P#38693 2017-03-24 15:38 ( Edited 2017-03-24 19:38)

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

P#38697 2017-03-24 19:17 ( Edited 2017-03-24 23:17)

[Please log in to post a comment]

Follow Lexaloffle:          
Generated 2024-03-29 01:46:57 | 0.007s | Q:13