Jump to content
  • Advertisement
Sign in to follow this  
Bobalandi

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.

If you intended to correct an error in the post then please contact us.

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 this post


Link to post
Share on other sites
Advertisement
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 this post


Link to post
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 this post


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

Share this post


Link to post
Share on other sites
Quote:
Original post by smitty1276
Quote:
Original post by TheUnbeliever
Or, 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 smitty1276
In any case, what's preventing you from just doing something like:
if (paused == false)
GameLogic();


Or, indeed,

if (!paused)
GameLogic();

Share this post


Link to post
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.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!