Sign in to follow this  
lodoss118

pausing in a game?

Recommended Posts

Boder    938
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
deadimp    310
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
ricekrispyw    388
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
RuneLancer    253
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
lodoss118    102
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
Rob Loach    1504
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

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this