It is currently Wed Dec 30, 2009 8:49 pm
All times are UTC


Welcome
Welcome to <strong>PresStart</strong>.
[url=http://presstart.freeforums.org/profile.php?mode=register]Join[/url] PresStart today!


Post new topic Reply to topic  [ 11 posts ] 
Author Message
 Post subject: Pause (Easy/intermediate,GML used,GM Pro Required)
PostPosted: Fri Jul 18, 2008 11:46 pm 
Offline
DYNOMITE!
User avatar

Joined: Thu Jul 03, 2008 8:10 am
Posts: 40
Location: USA
This will show you how to make a pause screen. We will start by making a simple black square sprite. The size does not matter. Also, create a font called "font1". Make it however you like.

Next make a script. Name it "game_pause".
Here is the code for the script:
{
draw_set_color(c_red);
//sets the color for the font later
draw_set_font(font1)
//sets a font that you made; "B_system" was my font's name;
draw_sprite_stretched_ext(sprite0,0,0,0,room_width,room_height,c_black,168);
draw_text(32,176,"Game Paused: Press any key to continue")
//draws the text "Game Paused: Press any key to continue"
screen_refresh();
//refreshes the screen using the current room image
keyboard_wait();
//makes the code wait for somebody to press a keyboard button
io_clear();
//clears the keyboard
}


Now, make an object. Its probably better to make it a main. (If you don't know. A main is an object that has no sprite. Its only purpose is to set variable to complete a task in a room.) Now add a key press event (any key). I will set mine to key press "P". And put an execute code action in.

Add this code:
game_pause();

Now, put the object in the game and start it up! Ok. Like it? Or maybe you don't want the black background. You can simply change the color of the sprite or if you don't want it at all do the following.

First, delete the sprite and remove this bit of code from the "game_pause" script: "draw_sprite_stretched_ext(sprite0,0,0,0,room_width,room_height,c_black,168);".

Thats all there is to removing the background. What if your game only uses the mouse? Simply change "keyboard_wait();" to "mouse_wait();" in the "game_pause" script to make the mouse unpause it.

If you have any questions or ideas post them below.

_________________
I am an Image in the Game Maker Quiz!

Image


Top
 Profile  
 
 Post subject:
PostPosted: Sat Jul 19, 2008 1:42 am 
Offline
DYNOMITE!
User avatar

Joined: Thu Jul 03, 2008 8:10 am
Posts: 40
Location: USA
Entering and remembering these codes everytime you need to make a game can get to be very annoying. Thats why I will show you how to turn it into an action button. We will use the Action Library Maker. If you don't have it you can download it here:

http://www.yoyogames.com/extensions (It has Action Library Maker and Extension Maker)

This is where the easy part ends and the intermediate part starts. In this tutorial I will guess that you have never used Action Library Maker before. It adds action buttons that you can use in your games. Be sure to follow the tutorial as close as possible. One mistyped letter can mess up the entire thing. So, lets begin.

Start up Action Library Maker and we will first make your new tab:
Image

Where it says "Enter your title here" put a name for your tab. Then go down and click on the "Add" button.
Image
Put "Pause" for the name and make a short description for it. Now, at the bottom left it says type. Select code. Then click on the code button that appears. This will come up:
Image

Now here is the code to put in:
{
draw_set_color(argument0);
//sets the color for the font later
draw_set_font(argument1)
//sets a font that you made; "B_system" was my font's name;
draw_sprite_stretched(argument2,0,0,0,room_width,room_height);
draw_text(32,176,argument3)
//draws the text "Game Paused: Press any key to continue"
screen_refresh();
//refreshes the screen using the current room image
if argument4 =0
{
keyboard_wait();
//makes the code wait for somebody to press a keyboard button
}
else
{
mouse_wait();
}

io_clear();
//clears the keyboard
}

Its diffrent from the code we put in above. The argument part will make sense in a minute. Here is the screenshot for the next set of instructions. Look at it first so you can see what I mean:
Image

Unselect the Question, Show "Apply to", Show "Relative" if they are checked
In the argument count change the number to 5.
Now a bunch of boxes will appear. For the first row (going down) put the following text in.

In the first box put "Text Color" in.
For the second box put in "Font".
Third "Background Sprite"
Fourth "Pause Message"
Last put "Unpause on".

The second and third row (going down) should match my screen shot except for the "Pause Message" one. Its secondary box should be set to a string!

After you put Menu in for the last box on the second row another box will appear. Put this in it:
"Keyboard|Mouse"

Now click the save button at the top. THIS IS IMPORTANT!!! Save it to:
C:/Program Files/Game_Maker7/lib/

Save it and open Game Maker. Now create a sprite. Make it a black box with any size. Also, create a font. Make it however you like. Make an object and create a "On keyboard Press P" event. Go to our new tab. Drag our new action onto the action list. Fill in the Arguments (you should know what they are for now). And test it out! If it doesn't work you may have missed something in the tutorial. If it works than you don't have to memorize that long code now!

There you go! You made your first Action Library :!:

If you have any questions or problems please post them below! :)

_________________
I am an Image in the Game Maker Quiz!

Image


Top
 Profile  
 
 Post subject:
PostPosted: Sat Jul 19, 2008 3:37 pm 
Offline
The PresStart Admin Counsel

Joined: Thu Jan 31, 2008 1:48 am
Posts: 108
lol you are crazy man! How did you learn all this stuff? I'm 99% self taught on the software!

_________________
Where the fun is at!
http://www.presstartpro.com/


Top
 Profile  
 
 Post subject:
PostPosted: Sat Jul 19, 2008 5:41 pm 
Offline
DYNOMITE!
User avatar

Joined: Thu Jul 03, 2008 8:10 am
Posts: 40
Location: USA
I'm completely self taught. Making an action library is EXACTLY like making a script with arguments. I just hate having to copy the script each and every time so I just turned it into a button. After you make your first one (and understand how it works) it is really easy after that.

_________________
I am an Image in the Game Maker Quiz!

Image


Top
 Profile  
 
 Post subject:
PostPosted: Sun Jul 20, 2008 7:02 pm 
Offline
The PresStart Admin Counsel

Joined: Thu Jan 31, 2008 1:48 am
Posts: 108
Wait so when you make something, it adds it to the action lists when making an object? As in the stuff on the right side of the obj properties window?

_________________
Where the fun is at!
http://www.presstartpro.com/


Top
 Profile  
 
 Post subject:
PostPosted: Sun Jul 20, 2008 7:06 pm 
Offline
DYNOMITE!
User avatar

Joined: Thu Jul 03, 2008 8:10 am
Posts: 40
Location: USA
Yep. Exactly!

_________________
I am an Image in the Game Maker Quiz!

Image


Top
 Profile  
 
 Post subject:
PostPosted: Wed Jul 23, 2008 10:47 pm 
Offline
The PresStart Admin Counsel

Joined: Thu Jan 31, 2008 1:48 am
Posts: 108
That's really cool! Here is a good idea for your site then. You should make new commands for the action library and allow people to download them off your site!

_________________
Where the fun is at!
http://www.presstartpro.com/


Top
 Profile  
 
 Post subject:
PostPosted: Fri Jul 25, 2008 4:15 am 
Offline
DYNOMITE!
User avatar

Joined: Thu Jul 03, 2008 8:10 am
Posts: 40
Location: USA
I thought about that for a while but I don't have enough buttons to make a full tab. When I think of enough buttons I will but for now I just don't have enough.

_________________
I am an Image in the Game Maker Quiz!

Image


Top
 Profile  
 
 Post subject:
PostPosted: Sat Jul 26, 2008 3:37 am 
Offline
The PresStart Admin Counsel

Joined: Thu Jan 31, 2008 1:48 am
Posts: 108
Start thinking some very creative stuff, like make a mic input tool or cool things like that!

_________________
Where the fun is at!
http://www.presstartpro.com/


Top
 Profile  
 
 Post subject:
PostPosted: Sat Jul 26, 2008 6:57 pm 
Offline
DYNOMITE!
User avatar

Joined: Thu Jul 03, 2008 8:10 am
Posts: 40
Location: USA
I'm limited to things that I can do in GML. I only just started learning C++ a few days ago. I still can't do very much with it. If I could use it with Game Maker then I might be able to do something like that.

_________________
I am an Image in the Game Maker Quiz!

Image


Top
 Profile  
 
 Post subject:
PostPosted: Sat Jul 26, 2008 7:04 pm 
Offline
The PresStart Admin Counsel

Joined: Thu Jan 31, 2008 1:48 am
Posts: 108
I tried to learn C++ once but it is so crazy. I do know Blitz Basic and 3D Basic languages though!

_________________
Where the fun is at!
http://www.presstartpro.com/


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 11 posts ] 

It is currently Wed Dec 30, 2009 8:49 pm
All times are UTC

Who is online

Users browsing this forum: No registered users and 0 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum