PDA

View Full Version : To create a pause game function



SlaynX
20th June 2011, 12:46
Hi there,

Let say I'm developing a widget game for Symbian^3, and this game is actually a fast pace object falling down game.(Sometimes more than 1 objects can fall together) So what's is the simplest yet effective way to create a pause function for such a game?
Thank you in advance.

FelixB
20th June 2011, 12:53
that depends on your game logic. maybe it's sufficient to set a bool "moving" which is set to false when paused. in your code, you check the state of "moving" and move the objects only if true.

wysota
20th June 2011, 13:00
The simplest and most effective way to create a pause is to stop the timer.

SlaynX
20th June 2011, 14:42
Wysota I'm not clear what you mean by stop the timer. Is it to stop the timer which control the object to fall down or is there some internal timer which I do not know of. Please enlighten me. :confused:

wysota
20th June 2011, 14:42
Stop the timer that you have that controls the game loop.

SlaynX
21st June 2011, 17:57
But isn't stopping the QTimer will literally stop the timer which makes resuming the game can be pretty ugly because the QTimer will restart the interval again upon resuming.

squidge
21st June 2011, 19:19
I wouldn't have thought it was be noticable.

After all, you would execute the game loop once per timer event, so stopping and then restarting the timer would have no real drawback.

wysota
21st June 2011, 20:51
You can always stop the timer from within the method executed as a result of the timer's timeout. Or you can calculate how much time is left till the next timeout and correct the interval while resuming the game. But I think it doesn't matter if the game loop triggers 10ms or 9ms after unpausing the game.