ZFGC

Resources => Coding => Topic started by: King Tetiro on April 13, 2006, 11:44:20 am

Title: [Request / Listing] Solved-Save Files
Post by: King Tetiro on April 13, 2006, 11:44:20 am
I have made my game on game maker version 6.1 and I'm having trouble with my inventory. It's an object but I want it to pause everything apart from it until it's destroyed/closed PLEASE HELP! :'(
Title: Re: Inventory Pause trouble
Post by: King Tetiro on April 13, 2006, 11:46:49 am
i could be version 6 I don't know
Title: Re: Inventory Pause trouble
Post by: Ben on April 13, 2006, 11:51:25 am
The usual way to do it is have a global variable called global.pause.
Now this will be a boolean (can either be true or false). And basically you encompass everything that you don't want to happen when paused within
if (!global.pause){
//code here
}

Now when you open your inventory you set global.pause to true, and so no code is called (because that if will only let you through when global.pause is false). Then when you close it you set global.pause to false, so everything else is called.

Edit: Oh and btw, that modify button up there can be your friend, and it'll stop all the mean kids being mean to you. AKA don't double post.
Title: Re: Inventory Pause trouble
Post by: King Tetiro on April 13, 2006, 12:04:37 pm
could kinda make this understandable, you see i'm not a fast understander (or make an example for little old me) and ta for the tip about the modify button
Title: Re: Inventory Pause trouble
Post by: Ben on April 13, 2006, 12:17:28 pm
Erm okay.
You've got your code in say the step event of your link object (i assume your making a zelda game).
So imagine your code is "doLinkStuff()"

Now to make it pausable you do this:

Code: [Select]
if (!global.pause){
doLinkStuff();
}

Now I dont' know how your using your inventory, but if your just creating an inventory object then in the create event of that you put:
Code: [Select]
global.pause = true;
And if in getting rid of the inventory your destroying the object you put this in the destroy event:
Code: [Select]
global.pause = false;

Of course make sure that somewhere you've declared the variable first.

Now back to the bit with the if, you simply do this with the step code of every object, and then it *should* work.
Title: Re: Inventory Pause trouble
Post by: King Tetiro on April 13, 2006, 12:28:27 pm
I don't mean to sound rude but would you mind making an example for me. Cos I still don't get it! (Sorry for the bother)
Title: Re: Inventory Pause trouble
Post by: King Tetiro on April 13, 2006, 01:27:59 pm
Or you could show how to do it in great detail (if you want to if you don't that's okay)
Title: Re: Inventory Pause trouble
Post by: therabidwombat on April 13, 2006, 02:32:41 pm
Lagionaz, the best way to learn is to try. So I'll give you a short example of how it works, and you can try to figure it out from there.

Your object is a horse. During the 'step' event, your horse executes the following code:

Code: [Select]
self.dir = floor(random(4));
if (self.dir = 0)
{
  x -= 1;
}
else if (self.dir = 1)
{
  y -= 1;
}
else if (self.dir = 2)
{
  x += 1;
}
else
{
  y += 1;
}

Now, obviously, this code would not really look very good if you actually ran it, but for example purpose, let's pretend that that makes sense.

Now, say that you created an object that, when it's running, you want to pause the game. In the create even of that object, you'd put the code:

Code: [Select]
global.pause = true;
and in the destroy event, you'd put the code:

Code: [Select]
global.pause = false;
you would also need, at the point where your game starts, to put code that says:

Code: [Select]
global.pause = false;
if you hadn't set 'set uninitialised variables to 0' in your preferences.

Once you have that set up, go back int your hourse object, and alter the code this way:

Code: [Select]
[b]if (!global.pause)  //if the game isn't paused[/b]
{
  self.dir = floor(random(4));
  if (self.dir = 0)
  {
    x -= 1;
  }
  else if (self.dir = 1)
  {
    y -= 1;
  }
  else if (self.dir = 2)
  {
    x += 1;
  }
  else
  {
    y += 1;
  }
[b]}[/b]

This will make it so that the code that moved the horse only ever executes if the game is not paused, which the object will tell the game.

Just a tip for asking for help in the future, people are more willing to help you if you tell them what you have tried, instead of just jumping on here as soon as you have to do something. Additionally, if you have something else to say after you've already posted, and Ben has already said this but you obviously didn't listen, click on the 'modify' button on your old post instead of making a new post if no one else has posted in the topic yet. Posting in the same topic twice in a row is known as 'double posting' and is generally frowned upon in forums, which is one reason why the modify button is there - so that you can add more to your old post without double posting.
Title: Re: Inventory Pause trouble
Post by: Halu on April 13, 2006, 03:07:31 pm
An easier way to do it would to have in the Create event of the Menu, the code
instance_deactivate_all(1);
And when you press a key, it destroys the menu and it activates the objects using instance_activate_all();
And if you had, like, a pointer object, then do the exact same code for that as you did for the menu.
Title: Re: Inventory Pause trouble
Post by: therabidwombat on April 13, 2006, 06:33:24 pm
The only problem with that way, halotank, is that it causes everything else to disappear.

I had a function that would run a menu, without needing to pause the game because it was just one function, and the game lets functions run while pausing the game at the same time, but that's probably a little too complex for you at this point.
Title: Re: Inventory Pause trouble
Post by: Ben on April 13, 2006, 06:39:23 pm
All you have to do is put the entire thing within a while loop, it's not that hard, but then your right it's probably too hard for him.
I daresay you shouldn't start here in GM anyway.
Jumping into coding isn't helpful.
Title: Re: Inventory Pause trouble
Post by: King Tetiro on April 13, 2006, 07:19:12 pm
I'm very good at game maker so what you lot are saying is that in the create event you put global.pause to be true and destroy event it's false. SOOOOO if I got the idea in the step event of say a hero if the global.pause is true, then the thing should pause
(the underline is that I don't understand how)
Title: Re: Inventory Pause trouble
Post by: Ben on April 13, 2006, 07:21:48 pm
You understand the idea of code blocks right?
As in:
Code: [Select]
if (var == true){
Dostuff();
DoMoreStuff();
DoSomethingElse();
}

Now in your link object find the step code that you using and at the beginning put:
Code: [Select]
if (global.paused == false){

And at the end put

Code: [Select]
}
Title: Re: Inventory Pause trouble
Post by: King Tetiro on April 13, 2006, 07:37:04 pm
So do you use sleep for ..... icon
Title: Re: Inventory Pause trouble
Post by: Ben on April 13, 2006, 07:38:42 pm
Are you using code or Drag and drop? :S
Title: Re: Inventory Pause trouble
Post by: King Tetiro on April 13, 2006, 07:40:03 pm
Drag and drop (I used it a heck of a lot that's how I did my complete heart piece system)
Title: Re: Inventory Pause trouble
Post by: therabidwombat on April 14, 2006, 03:47:19 am
This would be a heck of a lot harder in drag and drop..


actually I can't even imagine making a zelda game in drag and drop. Holy cow that'd take forever.
Title: Re: Inventory Pause trouble
Post by: King Tetiro on April 14, 2006, 07:00:49 am
Not really I nearly have my SECOND demo done
Title: Re: Inventory Pause trouble
Post by: Kleaver on April 15, 2006, 01:51:58 pm
Laigonaz, stop the triple posting...edit your post if you want to say more...
Title: Re: Inventory Pause trouble
Post by: Piers on April 15, 2006, 02:09:39 pm
This would be a heck of a lot harder in drag and drop..


actually I can't even imagine making a zelda game in drag and drop. Holy cow that'd take forever.
Actually its not as hard as it seems. Most Gml has a d&d equivalant.
Title: Re: Inventory Pause trouble
Post by: Windy on April 15, 2006, 03:25:44 pm
This would be a heck of a lot harder in drag and drop..


actually I can't even imagine making a zelda game in drag and drop. Holy cow that'd take forever.
Actually its not as hard as it seems. Most Gml has a d&d equivalant.
i think he's referring to the fact that most zelda games require several thousand lines of code
which would probably take you a while to d&d all that
plus you lose all the benefits of readable and modifiable code (which i would consider essential when developing a game of this size)
Title: Re: Inventory Pause trouble
Post by: Piers on April 15, 2006, 06:13:12 pm
This would be a heck of a lot harder in drag and drop..


actually I can't even imagine making a zelda game in drag and drop. Holy cow that'd take forever.
Actually its not as hard as it seems. Most Gml has a d&d equivalant.
i think he's referring to the fact that most zelda games require several thousand lines of code
which would probably take you a while to d&d all that
plus you lose all the benefits of readable and modifiable code (which i would consider essential when developing a game of this size)
And then theres the Dlls and modifialble scripts which can't be done with d&d. But then again d&d has Libs which can make it so you can do more.
Title: Re: Inventory Pause trouble
Post by: King Tetiro on April 15, 2006, 08:51:46 pm
Don't woory I've done it but there's a new problem, save files, need to be able to have three (traditional amount for zelda games) any help?
Title: Re: Save Files?
Post by: Ben on April 15, 2006, 08:57:06 pm
http://phreake.net/forums/index.php?topic=29.0

Just start a new topic next time, eh?
Title: Re: Save Files?
Post by: King Tetiro on April 15, 2006, 08:59:49 pm
Sure but in a way it lead up to this so in a way I didn't need to (Inventory with save function)
Title: Re: Save Files?
Post by: Ben on April 15, 2006, 09:01:16 pm
In a way it did? There's a remote link seeing as they're both types of engine for a zelda game, but people will look in the topic and be all "wtf? this isn't about save files".
Title: Re: Save Files?
Post by: King Tetiro on April 15, 2006, 09:03:00 pm
TRUE but I need this really much for my THIRD demo
Title: Re: Solved-Save Files
Post by: AoDC on April 16, 2006, 11:30:28 pm
I 100% suggest you look at this file.

"GameMaker D&D and their GML Equivalents."
http://www.rocketsoft.gm-school.uni.cc/uploads/dd_icons_to_gml.zip

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