Jump to content
  • Advertisement
Sign in to follow this  
lodoss118

pausing in a game?

This topic is 4796 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

Advertisement
while(pause)
{
if(keyboard.hit())
break;
pause_screen.draw();
sleep(100);
}


[Edited by - Boder on June 4, 2005 9:04:30 PM]

Share this post


Link to post
Share on other sites
You can:
> Make it freeze until a key is pressed, as Boder states
> Prevent your game from updating certain objects, and only have them draw (this will only work if your objects have two separate functions for stepping and drawing, where drawing will not update anything)
For a more detailed reply, we need to know the basic structuring of your game.

Share this post


Link to post
Share on other sites
It kind of depends on how you are hanfling game states. With this system it's pretty easy, and with the Task/Kernel system it's pretty easy. How you deal with game states is going to define how you handle a pause.

Share this post


Link to post
Share on other sites
Make a game state manager which handels the game state of the game and then set the game state to pause. Which would stop all loops and draw a screen of some sort, or just grab the current screen image and dim it and write the word "paused" in the center.

Share this post


Link to post
Share on other sites
The easiest way to do this is just to have a flag declared in your main game loop. Set it to true when paused, and false when not paused. Then you can use this to decide how to handle your game loop (most likely, handle window messages, read inputs (but discard anything not pause-related), and refresh display.)

If you're using an object-oriented approach to your game, you could just have a "isPaused" member in your class which can be used to determine how to handle stuff. For instance, the map class in an RPG might only redraw the map and skip the code that handles NPC/player movement when this flag is set.

Share this post


Link to post
Share on other sites
thanks guys and my structure is not in OO design because i am a newbie so basically i have intiliase sprites/objects render objects then i have my game loop
which the render functions go in and the controls and any conditions

Share this post


Link to post
Share on other sites
Game states are definately the way to do it. You'd have one state for InGame and another called GamePause or something and then when the player presses the pause button, switch between the two. The article ricekrispyw posted looks pretty good, I suggest you look into it.

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.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!