Hello Guest, please login or register.
Did you miss your activation email?
Login with username, password and session length.

Pages: [1] 2   Go Down

Author Topic: [Request]: Pausing  (Read 4197 times)

0 Members and 1 Guest are viewing this topic.

Dark-Hylian

Silence
[Request]: Pausing
« on: February 11, 2010, 10:44:12 pm »
  • *
  • Reputation: +0/-0
  • Offline Offline
  • Gender: Male
  • Posts: 370
Is there a way, using GM8, to pause everything but a menu and menu related objects? I'm not sure how most people do their menus, but the two plausible methods seem to be:

Pause everything else and leave the menu to be screwed around with.

or

Using Persistant in a room, changing rooms to a menu room, then going back.

If using the first, how would one manage to pause, and if using the second, would that disrupt the game's flow? As in, resetting things outside of the persistant setting?
Logged
  • Dawning Hour
Re: [Request]: Pausing
« Reply #1 on: February 11, 2010, 11:08:32 pm »
  • *
  • Reputation: +10/-0
  • Offline Offline
  • Gender: Female
  • Posts: 1469
I would consider having a global variable set, called Paused or something. Have every object check if Paused = 0 before every single action. Then all you need to do is have that set to 1 when the pause menu opens, and viola, everything freezes.
Logged
  • Elliott Parkinson

Dark-Hylian

Silence
Re: [Request]: Pausing
« Reply #2 on: February 11, 2010, 11:32:13 pm »
  • *
  • Reputation: +0/-0
  • Offline Offline
  • Gender: Male
  • Posts: 370
It worked for the most part, but when I pause while rolling, it freezes the image, then when I unpause, it keeps going with the image frozen, and doesn't stop. Currently attempting to fix that, but it worked for almost everything else.
Logged
  • Dawning Hour

Mamoruanime

@Mamoruanime
Re: [Request]: Pausing
« Reply #3 on: February 11, 2010, 11:59:37 pm »
  • ^Not actually me.
  • *
  • Reputation: +9/-0
  • Offline Offline
  • Gender: Male
  • Posts: 9786
Well; the general idea behind a pause function is that it stops your game from "updating". Your update loop is the Step event in GM.

Basically, before any code in your step events are executed, you want a line of code in that breaks away from the rest.

Pseudo coding;

if pause = true{
return
}

or the equiv. of return in GML. This will force the script to exit the event if it's paused. You want that in everything except your menu step events.

Logged

Dark-Hylian

Silence
Re: [Request]: Pausing
« Reply #4 on: February 12, 2010, 03:14:28 am »
  • *
  • Reputation: +0/-0
  • Offline Offline
  • Gender: Male
  • Posts: 370
I tried four different variations of the pause=true style of pausing, none of them working well, so I'm using http://gmc.yoyogames.com/index.php?showtopic=47475 .

It works well, up until unpausing. When I unpause, the character isn't there. Then when I hit space again, it moves the character back to where it was when the room began(see screenies).

Any idea on how to fix this?
Logged
  • Dawning Hour

Mamoruanime

@Mamoruanime
Re: [Request]: Pausing
« Reply #5 on: February 12, 2010, 04:35:47 am »
  • ^Not actually me.
  • *
  • Reputation: +9/-0
  • Offline Offline
  • Gender: Male
  • Posts: 9786
My honest opinion is that I think you're overcomplicating the process. It's not something that requires an engine or anything. It's as simple as adding a couple lines of code in the step events of the objects you want to pause, and a global boolean variable for "paused".
Logged
Re: [Request]: Pausing
« Reply #6 on: February 12, 2010, 06:45:11 am »
  • *
  • Reputation: +16/-0
  • Offline Offline
  • Gender: Male
  • Posts: 1633
This is how I did it:
Create a surface of the screen. Turn it into a sprite and create an object in the top left corner of the view using it in the draw event. The depth obviously should be over all other regular objects. Next deactivate all object and you've paused. Reactivate and destroy the temp surface to unpause. All speeds, direction and alarms get saved for you so (to me) it seems like the most efficient methode. I like using a temporary object because of the flexibility, but doing it all in code should work just as well.

Just reactivate the objects the do need during, like a menu object and have the depth over the screenshot.
Logged
Re: [Request]: Pausing
« Reply #7 on: February 12, 2010, 09:16:01 am »
  • *
  • Reputation: +0/-0
  • Offline Offline
  • Posts: 2245
This is how I did it:
Create a surface of the screen. Turn it into a sprite and create an object in the top left corner of the view using it in the draw event. The depth obviously should be over all other regular objects. Next deactivate all object and you've paused. Reactivate and destroy the temp surface to unpause. All speeds, direction and alarms get saved for you so (to me) it seems like the most efficient methode. I like using a temporary object because of the flexibility, but doing it all in code should work just as well.

Just reactivate the objects the do need during, like a menu object and have the depth over the screenshot.
Alternatively, if you aren't registered I would recommend deactivating all objects and putting up dummy objects in their place that have the same sprite and image index.
Logged

Mamoruanime

@Mamoruanime
Re: [Request]: Pausing
« Reply #8 on: February 12, 2010, 10:41:18 am »
  • ^Not actually me.
  • *
  • Reputation: +9/-0
  • Offline Offline
  • Gender: Male
  • Posts: 9786

I've attached an example of how simple this is.

objController handles pausing. Hit Enter to pause. Whatever menus you need to execute can be created from that if need be. In order for the menu to execute, leave the if global.paused = true bit out of their code. Easy as pie.

..And please, for the love of pete, don't create a ton of objects or rooms to do this task D: It's so unnecessary.
« Last Edit: February 12, 2010, 10:53:59 am by Mamoruanime »
Logged
Re: [Request]: Pausing
« Reply #9 on: February 12, 2010, 03:41:53 pm »
  • Mr. Pixel
  • *
  • Reputation: +1/-0
  • Offline Offline
  • Gender: Male
  • Posts: 245
I use deactivating and activating objects, expect the menu object.
For registered version I would recommend taking screenshot just before
deactivating and drawing it behind menu screen, if you want stayimage.
After unpausing you can destroy the image.
Logged

Ryuza

That one guy
Re: [Request]: Pausing
« Reply #10 on: February 12, 2010, 07:39:38 pm »
  • RyuKage2007
  • *
  • Reputation: +0/-0
  • Offline Offline
  • Gender: Male
  • Posts: 290
I attached a quick example I made showing how to pause by activating and deactivating objects.
Logged
<- Koholint Island - MC Style  <- Link's Awakening Photo Recolors  <- Wind Waker 3D Resources <- Super Mario Bros Crossover
  • RyuKage2007's Youtube
Re: [Request]: Pausing
« Reply #11 on: February 12, 2010, 08:11:36 pm »
  • *
  • Reputation: +9/-0
  • Offline Offline
  • Gender: Male
  • Posts: 3725
Hmm, RyuKage yours seems a bit complicated. Mammy's idea is a lot simpler.
Logged

Ryuza

That one guy
Re: [Request]: Pausing
« Reply #12 on: February 12, 2010, 08:34:44 pm »
  • RyuKage2007
  • *
  • Reputation: +0/-0
  • Offline Offline
  • Gender: Male
  • Posts: 290
Mammy's is pretty simple, but if do it that way you have to put an extra line of code into every object you create that would be affected by pausing. I found the activate/deactivate way much easier overall.
Logged
<- Koholint Island - MC Style  <- Link's Awakening Photo Recolors  <- Wind Waker 3D Resources <- Super Mario Bros Crossover
  • RyuKage2007's Youtube
Re: [Request]: Pausing
« Reply #13 on: February 12, 2010, 08:48:21 pm »
  • *
  • Reputation: +9/-0
  • Offline Offline
  • Gender: Male
  • Posts: 3725
That feature is depricated, because correct functioning could not be garanteed. Besides, my biggest problem with your example is that you call activate/deactivate each step instead of when it needs to be done at a key press.
Logged

Ryuza

That one guy
Re: [Request]: Pausing
« Reply #14 on: February 12, 2010, 09:04:55 pm »
  • RyuKage2007
  • *
  • Reputation: +0/-0
  • Offline Offline
  • Gender: Male
  • Posts: 290
Ah, I probably should just add it into the key press event, what do you mean by it not being guaranteed to function correctly?
Logged
<- Koholint Island - MC Style  <- Link's Awakening Photo Recolors  <- Wind Waker 3D Resources <- Super Mario Bros Crossover
  • RyuKage2007's Youtube
Re: [Request]: Pausing
« Reply #15 on: February 12, 2010, 09:19:31 pm »
  • *
  • Reputation: +9/-0
  • Offline Offline
  • Gender: Male
  • Posts: 3725
Those activate/deactivate functions were known by Yoyogames to give a lot of problems and having unexpected results. That is why in GM8 it is called depricated and only put in for backwards compatibility.
Logged

Ryuza

That one guy
Re: [Request]: Pausing
« Reply #16 on: February 13, 2010, 01:59:26 am »
  • RyuKage2007
  • *
  • Reputation: +0/-0
  • Offline Offline
  • Gender: Male
  • Posts: 290
Ah, well, did they come up with some kind of alternate feature to do the same kind of thing?
Logged
<- Koholint Island - MC Style  <- Link's Awakening Photo Recolors  <- Wind Waker 3D Resources <- Super Mario Bros Crossover
  • RyuKage2007's Youtube

Mamoruanime

@Mamoruanime
Re: [Request]: Pausing
« Reply #17 on: February 13, 2010, 04:38:58 am »
  • ^Not actually me.
  • *
  • Reputation: +9/-0
  • Offline Offline
  • Gender: Male
  • Posts: 9786
Mammy's is pretty simple, but if do it that way you have to put an extra line of code into every object you create that would be affected by pausing. I found the activate/deactivate way much easier overall.

:x It's also very inefficient because of the errors it can give. It also prevents you from (if the need arises) executing code in locked objects while the pause is initiated.

Honestly, it's as simple as putting the code into a parent object's before-step event, and applying the parent to every object you want paused if you're worried about pasting 3 lines of code in. There are also some more creative ways of doing it that only require you to use those 3 lines of code once.
« Last Edit: February 13, 2010, 04:48:58 am by Mamoruanime »
Logged
Re: [Request]: Pausing
« Reply #18 on: February 13, 2010, 07:05:27 am »
  • AKA "Micah DS"
  • *
  • Reputation: +9/-0
  • Offline Offline
  • Gender: Male
  • Posts: 1347
I've attached an example of how simple this is. ...

At first I thought you really had a simple fix here, but..
If this is used, alarms will not function properly. Now, alarms might be an easy work-around (counters/timers are easy), but what about friction and gravity? Simply exiting the script won't handle these things properly. Think about it. Things could get tricky, no? :-\

I just think you have over-simplified. But you are still awesome Mamoru. ;)


... All speeds, direction and alarms get saved for you so (to me) it seems like the most efficient method. ...

After a bit more thought, I agree with Martijn. Even with the problems people have with activation and deactivation (though I've never had a problem :huh:), I do not think there is a better option here.
Martijn's LttP beta pauses everything just fine, and it has a lot of things going on with alarms and many movements of various objects. I think people have problems with the activate/deactivate functions because of misuse on their end; I do not think it's the program's fault.
Logged
  • My Music

Mamoruanime

@Mamoruanime
Re: [Request]: Pausing
« Reply #19 on: February 13, 2010, 07:10:17 am »
  • ^Not actually me.
  • *
  • Reputation: +9/-0
  • Offline Offline
  • Gender: Male
  • Posts: 9786
I've attached an example of how simple this is. ...

At first I thought you really had a simple fix here, but..
If this is used, alarms will not function properly. Now, alarms might be an easy work-around (counters/timers are easy), but what about friction and gravity? Simply exiting the script won't handle these things properly. Think about it. Things could get tricky, no? :-\

I just think you have over-simplified. But you are still awesome Mamoru. ;)

I didn't really over-simplify it though :P That sort of work is the users end. That's basically stuff you'd code in around the exit block (if global.paused = true). It's not going to eliminate the users need to program specific object's reactions to being paused. Besides; alarms, gravity, and friction are very simple fixes as well.
Logged
Pages: [1] 2   Go Up

 


Contact Us | Legal | Advertise Here
2013 © ZFGC, All Rights Reserved



Page created in 0.028 seconds with 78 queries.

anything