Jump to content


Photo
- - - - -

Classic Pause


  • Please log in to reply
46 replies to this topic

#31 Tarik

Tarik

    GMC Member

  • GMC Member
  • 2731 posts
  • Version:GM:Studio

Posted 24 October 2012 - 11:42 PM

A few comments from a few years back pointed out some of the difficulties in using this system. For example, using timers and various variables that aren't covered. (for example, I usually use a custom movement system that doesn't necessarily use gravity, speed etc, and creating unique holder variables for all the variables in the tens of datastructures I use isn't very practical.

Some also pointed out the option to use surfaces, or creating a sprite from the screen. But others pointed out surfaces don't work for everyone (I have to say though, this was mostly an issue in 2008 when a lot of people were still using old cards), and that not everyone can create screen-sized textures. (again, an old card issue, cards can normally always create a texture the size of the screen/resolution.)

If you still don't want to create new textures or surfaces, if you use pre-studio GM, I think all you'd need to do on pauze is to set automatic drawing off, change room to a pauze room, and then call screen refresh in the room and draw ontop any pauze message you'd like. On any keyboard input you'd switch automatic drawing back on and change the room back. Should be a few lines of code, all it requires is a persistent room. If you don't want that, just call room restart when you need to, and set it to persistent anyway.
  • 0

#32 DariusSlayer

DariusSlayer

    GMC Member

  • GMC Member
  • 70 posts
  • Version:GM:Studio

Posted 26 October 2012 - 06:53 PM

Yea, now all I get is this for a warning:

___________________________________________
FATAL ERROR in
action number 1
of Step Event1
for object Gameplay_UI:

############################################################################################
VMError!! Occurred - Push :: Execution Error - Variable Get pause
at gml_Object_Gameplay_UI_Step_1 (line -1) - <unknown source line>
############################################################################################


So, I did something right, I guess, that got rid of the other line of code causing an issue... I'm looking it over again and again but I really don't see how this error can come up :/
  • 0

#33 pixeltao

pixeltao

    GMC Member

  • GMC Member
  • 97 posts

Posted 26 October 2012 - 07:01 PM

Yea, now all I get is this for a warning:

___________________________________________
FATAL ERROR in
action number 1
of Step Event1
for object Gameplay_UI:

############################################################################################
VMError!! Occurred - Push :: Execution Error - Variable Get pause
at gml_Object_Gameplay_UI_Step_1 (line -1) - <unknown source line>
############################################################################################


So, I did something right, I guess, that got rid of the other line of code causing an issue... I'm looking it over again and again but I really don't see how this error can come up :/


Do you know if it's possible to open a GM Studio file with Game Maker 8.1? If that's the case, you could send me your project. It'd be easier to help you figure this out.
  • 0

#34 DariusSlayer

DariusSlayer

    GMC Member

  • GMC Member
  • 70 posts
  • Version:GM:Studio

Posted 26 October 2012 - 07:03 PM

Don't know if that's possible, but yea, I can try. PM me your emaill address, or if you want, we can text over Skype.
  • 0

#35 DariusSlayer

DariusSlayer

    GMC Member

  • GMC Member
  • 70 posts
  • Version:GM:Studio

Posted 26 October 2012 - 07:05 PM

As of now, I have an inventory box that appears when the game should pause.
  • 0

#36 rjj95

rjj95

    GMC Member

  • GMC Member
  • 196 posts
  • Version:Unknown

Posted 26 October 2012 - 08:13 PM

{
draw_set_font(font_pause);
draw_set_color(c_red);
draw_set_halign(fa_center);
draw_text(room_width/2,100, 'Game Paused. Press any key to continue');
screen_refresh();
keyboard_wait();
io_clear();
}
problem solved.
  • 0

#37 pixeltao

pixeltao

    GMC Member

  • GMC Member
  • 97 posts

Posted 27 October 2012 - 09:12 PM

@DariusSlayer: After some investigation, I believe that this error is caused by the fact that GM Studio doesn't set a default value to uninitialized variables. In this case, the pause variable is declared but never initialized to a value. To fix this, you have to add:
pause = 0;
In the Create event of the Controller after the pause global variable is declared. I edited the first post to include this modification.

@rjj95: Not really. Please read the first post before posting comments.
  • 0

#38 DariusSlayer

DariusSlayer

    GMC Member

  • GMC Member
  • 70 posts
  • Version:GM:Studio

Posted 06 November 2012 - 02:57 PM

WHen this code is in the Step Event (as it should be), "if ( pause ) exit;", all objects that can fire can not and my player can not move. When I remove this code, every one of those object function normally, but I can't pause... I've been starring at the main code for a while now and still can't figure it out. The function of the pause works. It really does and I'm glad that it does, but baffled as to why it's impeding the other functions.
  • 0

#39 NameDollars

NameDollars

    GMC Member

  • GMC Member
  • 8 posts
  • Version:GM8

Posted 28 December 2012 - 11:51 PM

When I put it in my object's Step event and try running my game to see it work, I get this message:

___________________________________________
COMPILATION ERROR in Script: pause
Error in code at line 6:
                           pause=1;
                                ^
at position 31: Variable name expected.
How can I fix this?
  • 0

#40 pixeltao

pixeltao

    GMC Member

  • GMC Member
  • 97 posts

Posted 29 December 2012 - 01:41 AM

When I put it in my object's Step event and try running my game to see it work, I get this message:

___________________________________________
COMPILATION ERROR in Script: pause
Error in code at line 6:
                           pause=1;
                                ^
at position 31: Variable name expected.
How can I fix this?


Did you follow exact the implementation explained in the 1st post? Because, if you put the pause code into a script, or make some changes to it, it might not work as intended.
  • 0

#41 NameDollars

NameDollars

    GMC Member

  • GMC Member
  • 8 posts
  • Version:GM8

Posted 29 December 2012 - 05:15 AM


When I put it in my object's Step event and try running my game to see it work, I get this message:

___________________________________________
COMPILATION ERROR in Script: pause
Error in code at line 6:
                           pause=1;
                                ^
at position 31: Variable name expected.
How can I fix this?


Did you follow exact the implementation explained in the 1st post? Because, if you put the pause code into a script, or make some changes to it, it might not work as intended.


I followed the instructions exactly, and only removed optional stuff I did not want. I did not add nor remove anything not optional and it is the only thing in its script.

EDIT: When I run your downloadable example with the changes I made, it runs normally. When I run my game after a copy/paste to make sure they are exactly the same, it has the same error come up.

Edited by NameDollars, 29 December 2012 - 08:27 AM.

  • 0

#42 pixeltao

pixeltao

    GMC Member

  • GMC Member
  • 97 posts

Posted 30 December 2012 - 10:41 PM



When I put it in my object's Step event and try running my game to see it work, I get this message:

___________________________________________
COMPILATION ERROR in Script: pause
Error in code at line 6:
                           pause=1;
                                ^
at position 31: Variable name expected.
How can I fix this?


Did you follow exact the implementation explained in the 1st post? Because, if you put the pause code into a script, or make some changes to it, it might not work as intended.


I followed the instructions exactly, and only removed optional stuff I did not want. I did not add nor remove anything not optional and it is the only thing in its script.

EDIT: When I run your downloadable example with the changes I made, it runs normally. When I run my game after a copy/paste to make sure they are exactly the same, it has the same error come up.


I can't easily tell you what's wrong in your implementation without having more details. Did you make sure that all of your objects have the pause variable initialized in their respective create event?

EDIT: Is it possible that you have an object named "pause" like the pause variable? This can create a conflict in your GM project. If that's the case, simply rename your pause object (or the variable).

Edited by pixeltao, 30 December 2012 - 10:45 PM.

  • 0

#43 NameDollars

NameDollars

    GMC Member

  • GMC Member
  • 8 posts
  • Version:GM8

Posted 31 December 2012 - 08:53 AM




When I put it in my object's Step event and try running my game to see it work, I get this message:

___________________________________________
COMPILATION ERROR in Script: pause
Error in code at line 6:
                           pause=1;
                                ^
at position 31: Variable name expected.
How can I fix this?


Did you follow exact the implementation explained in the 1st post? Because, if you put the pause code into a script, or make some changes to it, it might not work as intended.


I followed the instructions exactly, and only removed optional stuff I did not want. I did not add nor remove anything not optional and it is the only thing in its script.

EDIT: When I run your downloadable example with the changes I made, it runs normally. When I run my game after a copy/paste to make sure they are exactly the same, it has the same error come up.


I can't easily tell you what's wrong in your implementation without having more details. Did you make sure that all of your objects have the pause variable initialized in their respective create event?

EDIT: Is it possible that you have an object named "pause" like the pause variable? This can create a conflict in your GM project. If that's the case, simply rename your pause object (or the variable).


Thanks.

Hopefully unrelated, but may be, so still posting it here: Now my experience and HP bars aren't drawing when unpaused, but are when paused (using different objects for each) and the opponent HP still draws above them when unpaused. The codes are nearly exactly the same, but with changes for where they are drawn (EXP under the current/max, HP under current when paused, EXP 0,0, HP directly right of it when not). Again, not sure if related, but may be, so posting here to be safe.

EDIT: Never mind. Just a mistake in the coding by a guy too lazy to proof read.

Edited by NameDollars, 31 December 2012 - 10:25 AM.

  • 0

#44 Alphanumerai

Alphanumerai

    GMC Member

  • GMC Member
  • 16 posts
  • Version:GM8.1

Posted 16 March 2013 - 03:34 PM

Just wanted to say I'm using your pause system in my NES/SMS inspired project.
It originally appealed to me as it doesn't blank the screen of obscure it with a horrible dialogue box, so you can have your own menus.
I'm also going to use it for screen transitions, pausing everything and moving the view and player, while altering their recorded variables. To give the same affect as when you cross the screen in games like Mega Man.
Just have to add something to determine whether it was paused by the player or the game, to allow control or not ^_^

Best pause system I've found.
  • 0

#45 pixeltao

pixeltao

    GMC Member

  • GMC Member
  • 97 posts

Posted 17 March 2013 - 12:53 AM

Just wanted to say I'm using your pause system in my NES/SMS inspired project.
It originally appealed to me as it doesn't blank the screen of obscure it with a horrible dialogue box, so you can have your own menus.
I'm also going to use it for screen transitions, pausing everything and moving the view and player, while altering their recorded variables. To give the same affect as when you cross the screen in games like Mega Man.
Just have to add something to determine whether it was paused by the player or the game, to allow control or not ^_^

Best pause system I've found.


Awesome, glad you like it ^_^ I'm a fan of NES/SMS style games. I'd be curious to try it when it's ready.
  • 0

#46 icuurd12b42

icuurd12b42

    Self Formed Sentient

  • Retired Staff
  • 15729 posts
  • Version:GM:Studio

Posted 18 March 2013 - 08:42 PM

Please dont name the function the same as a variable. I think that is the problem here.

 

COMPILATION ERROR in Script: pause

 

pause=1;


  • 0

#47 Ruub

Ruub

    Finn The Human

  • GMC Member
  • 602 posts
  • Version:GM:Studio

Posted 22 March 2013 - 09:34 AM

hey pixeltoa,

 

I figured, isn't it easier to have one control that puts in all the variables instead of having to put it in every create event?

 

//Roomstart event because persistent ;D
with (all)
{
if object_index=obj_controller
or object_index=obj_smoothbackground
or object_index=obj_megafox
or object_index=obj_cursor
{pause_able=0; exit;}

pause_able=1;
}

Edited by Ruub, 22 March 2013 - 09:36 AM.

  • 0




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users