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.
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
[Please log in to post a comment]