Page 1 of 2

Make a pause in the program

PostPosted: Sat May 07, 2011 9:55 am
by cedrique
Hello
I would put a pause in my script for more fluidity in a change of scenery from my "Pacman-test" ...
And I do not know how to do it!
I can knowledge in C, I learn at the same time as Game editor ...

If there is a need I can put the file so you can see where I am!

Thank you

Re: Make a pause in the program

PostPosted: Sun May 08, 2011 1:33 pm
by savvy
use pauseGameOn(); and PauseGameOff(); to pause and un-pause. in order for you to make a fluid menu with pause you have to make special variables in each of the characters to hold their speed and direction etc until un-paused. to make a menu you simple have to make it so it pauses only when the menu hits a certain transparency.
this menu can contain things such as "continue", "main menu", Exit game". simple 1 click things as when pause game is on you cant have any visual movement.
(when you press P)
Pause=1;
(on the menus draw event)

if(Pause==1)
{
transp-=0.1;
if(transp<=0)PauseGameOn();
}
if(pause==0)transp+=0.1;

(on the continue button)
PauseGameOff();
pause=0;
menu.transp=0.1; //this remove possibility of re-pausing

any help?

Re: Make a pause in the program

PostPosted: Wed May 11, 2011 7:36 am
by cedrique
Thanks for your help !

This is not what I wanted to do ... but you taught me to do a Fading!
I just wanted to make a pause in the script which is a shift in the stock ...

So, I found how to do with the timer!

Re: Make a pause in the program

PostPosted: Wed May 11, 2011 3:06 pm
by savvy
ah well, what can i do but try XD

Re: Make a pause in the program

PostPosted: Sat May 21, 2011 2:19 am
by SuperSonic
So how do "PauseGameOn" and "PauseGameOff" work? like, what does it pause and disable? :|

Re: Make a pause in the program

PostPosted: Sat May 21, 2011 7:21 am
by skydereign
PauseGameOn stops everything. Only events that end in exiting the game, loading another game, and unpausing the games work. I feel like I managed to get another event to trigger, but I can't seem to replicate it. That's why most people don't use PauseGameOn for more complex things.

Re: Make a pause in the program

PostPosted: Sat May 21, 2011 2:08 pm
by SuperSonic
Aha, thanks :D

Re: Make a pause in the program

PostPosted: Sun May 22, 2011 11:16 am
by savvy
yeees, its awkward because it means you cant have any moving parts in pause menus or anything working apart from maybe... a mouse click.
best thing for graphical purposes is to make pause variables etc. and actually make it YOURSELF.

Re: Make a pause in the program

PostPosted: Sun May 22, 2011 3:54 pm
by Jagmaster
savvy wrote:yeees, its awkward because it means you cant have any moving parts in pause menus or anything working apart from maybe... a mouse click.
best thing for graphical purposes is to make pause variables etc. and actually make it YOURSELF.

Someone needs to post a tutorial on this. I have no idea how to do this, and I'm sure there's lots of people like me who would like to learn how to make fancy pause menus with animations and such.
(Or maybe it's a well guarded secret :shock:)

Re: Make a pause in the program

PostPosted: Sun May 22, 2011 6:58 pm
by Game A Gogo
No secrets in GE should be well guarded!
You just have a variable named like "Paused", when it's 0, the game goes, when it's 1 the game stops!

But how to make the game go and stop? easy!

familiar with if()? and else?
Either way, if(condition) checks if condition is true, condition can be check with things like: == equal, > greater, >= greater or equal, < less, <= less or equal, != not equal.
more information: viewtopic.php?f=1&t=6834&p=48846#p48846

you can use else after an if statement to make something happen when the condition is not met.

so in every event that involves movement of your actor, you'll now add an if statement to it, and maybe some else too.

like say on key down:

Code: Select all
if(Paused==0)
{
    x+x=10;
}

Make sure to do it on all the movement involved actions in all moving actors!

You'll also need to create three actor variable, PauseT, lxvel and lyvel. Make sure they are actor variables! These variable will be to regain motion after pausing, since we want them to freeze up, any xvelocity and yvelocity would be set to zero. Not with me!
In draw actor you'd need:
Code: Select all
if(Paused==1)
{
    if(PauseT==0)//Makes this piece of code happen only once when paused!
    {
        PauseT=1;//With this...
        lxvel=xvelocity;//Storing current speed before stopping the actor
        lyvel=yvelocity;
    }
    xvelocity=0;
    yvelocity=0;
}
else
{
    if(PauseT==1)//Makes this piece of code happen only one when unpaused!
    {
        PauseT=0;//With this...
        xvelocity=lxvel;//Retrieving  speed before pausing, so there is no game-play lost!
        yvelocity=lyvel;
    }
}


Hopefully this helps.... I know it's not very detailed ):

Re: Make a pause in the program

PostPosted: Sun May 22, 2011 8:22 pm
by SuperSonic
But if "PauseGameOn" stops every event from working except the ones that end in "PauseGameOn" and "PauseGameOff", then if you wanted a menu with animated buttons then you could do this...
Code: Select all
MenuButton1 -> mouseover -> scripteditor

ChangeAnimation("Event Actor", "RandomAnimation", FORWARD);
PauseGameOn();

That way, you could have animated pause menus :P
Please correct me if I'm wrong :)

Re: Make a pause in the program

PostPosted: Sun May 22, 2011 9:38 pm
by lcl
SuperSonic wrote:But if "PauseGameOn" stops every event from working except the ones that end in "PauseGameOn" and "PauseGameOff", then if you wanted a menu with animated buttons then you could do this...
Code: Select all
MenuButton1 -> mouseover -> scripteditor

ChangeAnimation("Event Actor", "RandomAnimation", FORWARD);
PauseGameOn();

That way, you could have animated pause menus :P
Please correct me if I'm wrong :)

I'm not sure if this will work. You can try it though.

Re: Make a pause in the program

PostPosted: Sun May 22, 2011 10:12 pm
by skydereign
Events that only work are events that end in PauseGameOff, LoadGame, or ExitGame.

Re: Make a pause in the program

PostPosted: Mon May 23, 2011 3:21 pm
by savvy
here, this shows both a created pause AND a pausegameon/off, see what its like and take heed this: there are advantages and disadvantages of both.
http://dl.dropbox.com/u/9105634/pause%20tut.zip

savvy

Re: Make a pause in the program

PostPosted: Mon May 23, 2011 8:06 pm
by SuperSonic
Haha, (thingsthethingmakes) XD Where did you get that from?^^