Friday, January 28, 2011

How to pause your game.

This is something that almost every game needs to have. It is really easy to explain and do. First, you need to decide what button will pause your game. Most games will have the letter P pause the game. That is what we will use. Add Event, key press P. Now in the event of key press P put this code in.
Code:
{
io_clear();
draw_sprite(spr_gamepaused,0,150,170);
screen_refresh();
while (!keyboard_check_pressed(vk_anykey) ) sleep(100);
}

Ok, the second line in this code allows you to draw a sprite paused.
The rest of this code creates a loop. Keeping the game paused. And then the game will un pause when you hit any button. Simple right?

No comments:

Post a Comment