Public Group

Stop Clock (Pause)

This topic is 3966 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

Recommended Posts

I was playing around with this tutorial (http://www.gamedev.net/community/forums/topic.asp?topic_id=192483&PageSize=25), and I was trying to figure out a pause function, but I was having trouble, any of you have ideas how to pause it? Would I stop the game loop? If so, how? Thanks.

Share on other sites
Could you describe the problem in more detail? It looks like your link goes to a page which discusses a page that you are talking about...

In any case, what's preventing you from just doing something like:
if (paused == false)  GameLogic();

Share on other sites
Without reading the link, there are a few ways to implement a basic pause function.

1) stop calling Update() on objects you want paused (everything in the game world, probably, but NOT the GUI or input or you won't be able to unpause)

2) pass a zero time delta to the update objects to make them think no time has elapsed - not as good as option #1.

3) don't update the time at all

Share on other sites
Sorry, I linked to the last page, but I fixed it, if you could look, that would be great. :D

Share on other sites
Well, I tried

if(!paused)
{
do stuff
}

but it didn't work, it compiled, but nothing happened.

Share on other sites
Quote:
 Original post by TheUnbelieverOr, indeed....
Heh... I sometimes explicitly put the equality test for readability, but in this case "!paused" is certainly more readable.

Share on other sites
Quote:
Original post by smitty1276
Quote:
 Original post by TheUnbelieverOr, indeed....
Heh... I sometimes explicitly put the equality test for readability, but in this case "!paused" is certainly more readable.

Oops, I accidentally deleted the post when editing.

Quote:
Original post by TheUnbeliever
Quote:
 Original post by smitty1276In any case, what's preventing you from just doing something like:if (paused == false) GameLogic();

Or, indeed,

if (!paused)  GameLogic();

Share on other sites
I have a seperate gamestate for "paused" which draws and takes input, and updates some things but not others. My system is a little too complicated to post here, but its basically like having more than one game loop function, which call each other. e.g, your in the menu gamestate, which loads the renderer. Yu then start a game and the game goes into the loading gamestate, which uses the same renderer and subsystems. This state then exits and the playing gamestate is called. If you press escape, the playing gamestate calls the ingame menu gamestate, and when this gamestate exits, the playing loop continues. These are all methods within a "game engine" class, which is responsible for initializing the different subsystems before a call to each gamestate function. One of these states, paused, is a simple loop, which renders everything and takes input / output, but does not update any of the subsystems. e.g. my .md2 models are drawn when the game is paused, but not updated.

1. 1
2. 2
Rutin
21
3. 3
4. 4
A4L
15
5. 5
khawk
14

• 13
• 26
• 10
• 11
• 44
• Forum Statistics

• Total Topics
633742
• Total Posts
3013636
×