We're archiving the forums and going read only! You'll be able to see old threads, but new topics and replies have been disabled.

Visit the Game Jolt community for new questions and conversations.


Game Maker Language is a built-in programming language for Game Maker. It is perfect for creating a 2D nice game. I am not a GML expert. But I can help you on GML coding. I also expect help from you.

You can post in this topic:

  1. Your game idea in Game Maker.

  2. Any kind of script that can be used in Game Maker.

  3. Reply others for resolve their problems in GML.

If you are a developer and you use Game Maker, you may create Game Maker Libray or Extensions, Game Maker Tutorials, Game Maker Projects or something else that can help Game Maker users. I hope you will be share it with others. A beginner GML user may be an expert.


Page 1 of 87 replies.

almost 11 years ago

How to open a file with another program:

You can open a file with your program. *.html file will be open with it's default program (e.g. Google Chrome or Internet Explorer). But you want to open this file with Notepad from Game Maker. Use this code-

Syntax:

execute_shell( programname, filename);

Example:

execute_shell( "C:\Windows\notepad.exe", "D:\Documents\index.html");

This is very easy. You can use any command line with arguments.

Last modified on November 19, 2014 by RAF5UN @rafsun82

almost 11 years ago

Checking a code or password:

In your game you may need set password for any feature or level. How can you do this, described bellow:

Syntax:

var_code = get_string("Enter password here:","");

if var_code = password { if true } else { if false }

Example:

var_code = get_string("Enter password here:","");

if var_code = "PrInCe" { show_message("Correct!") } else { show_message("Wrong.") }

Last modified on November 19, 2014 by RAF5UN @rafsun82

almost 11 years ago

Tips 1:

If you use any built-in function, constant or variable name in a resource name, it may cause error.

almost 11 years ago

How to use menu:

Example:

argument = show_menu("Info|Close",2)

if argument = 0 { show_info() }; if argument = 1 { game_end() }

over 10 years ago

Tips 2:

Use sign "#" in a string for go to next line.

over 10 years ago

Tips 3:

For you older GM8 users avoid execute_string()! it crashes the game and causes errors on win8!

over 10 years ago

How to change mouse cursor in Lite:

In the lite edition of Game Maker you can change mouse cursor. Add a sprite like cursor and add an object, set the cursor sprite to it.Then, write the following codes in the Step event:

{ x = mouse_x; y = mouse_y }

Remember, the sprite origin must be at the pointer. You can change it.

Last modified on December 26, 2014 by RAF5UN @rafsun82

over 10 years ago

You used some sort of GML code or something in Tiny Ball on unlocking a level. How do you do that? Please let me know. I don't know about it.

over 10 years ago

"You used some sort of GML code or something in Tiny Ball on unlocking a level. How do you do that? Please let me know. I don't know about it."

could you explain your question better?

over 10 years ago

As you wish, PowerfulKyurem.

The Creator of the game, 'Tiny Ball' used some sort of code in unlocking a level. Suppose, you completed a level in this game, and some code or stuff appears in the 'save data.dat'. I just wonder how do he does that?

over 10 years ago

Unlocking level in "Tiny Ball

I used ini settings in my game. When level button is pressed, execute code:

if ini_read_string("CODE","L4","") = "XXXXXXXXX"
{
transition_kind = 21;
room_goto(6)
}
else
show_message('Complete the level first')

When, new level starts, execute code:

if room_get_name(room) = "ROOM NAME"
ini_write_string("CODE","L2","XXXXXXXX")

over 10 years ago

How to make an awesome save system in Game Maker. This uses Dnd only as it exploits a bug in GM. Well, sort of a bug. Not sure if it's a feature. xD as such, the exact names aren't given. You should easily be able to find the DNd blocks.

First, you need a save button and a save sound (at least 1 second long). This button creates an object as follows (or sends you to an empty room containing it):

Create event:

Play save sound

Start alarm 1 with 30 steps

save game

alarm 1 event:

Check if sound is playing. If not:

'restart' the game or rather, bring it back to whatever state it should be at upon reloading the game. I.E. Go back to the main menu.

Basically, have the game load the save upon starting. GM doesn't load sounds upon reloading, meaning that the game can tell the difference between a reload and just saving.

over 10 years ago

HOLD IT!

The code you're talking about, I used that before asking you. I used, but it never happened, but instead creating an error message. You used something like 'ini_read_string(section,key,default)'. I saw that you put some strings/word in section and key but why put spaces in default?

Also, you used the code as 'ini_read_string(section,key,default) == 0'. Where you put strings or words in section and key, and put spaces as usual in default, but why placing '==' and a value in front of a function?

Please answer the questions as soon as possible.

Last modified on December 21, 2014 by Ace-Pointer (R.I.P.) @Ace-Pointer

over 10 years ago

Answer to Mridha Ishmam.

I hope you know about the structure of an ini file.

  1. You have to use function - ini_open("<iniName>") to access an ini file.

  2. Default is a value (string or real) that only return when indicated section or key doesn't exists. I don't need default value in "Tiny Ball".

  3. When you use If Statement, it will check a function value. Like, if score = 50. If score is 50 then it will execute next code. Like, if score = 50 { show_message("Good!"); }. Some functions return true or false value. Like, file_exists(fname). Here you can use, if file_exists("save") = 0. Remember, 0 and false is same, 1 and true is same. If you don't use "= 0", it will execute next function if "file_exists" function is true. Like, if file_exists("save") { file_delete("save"); }.

  • *

over 10 years ago

Draw text with shadow:
You can use this code directly to your game. But you can't create extension from this code or distribute it. You must use this code in Draw event and set font for drawing before the code. Copy codes and fill arguments. Remove comment texts starts with "//".

Example:
{

  • argument0 = // Type here text(String)*

  • argument1 = // Type here X position of text*

  • argument2 = // Type here Y position of text*

  • argument3 = // Position of shadow (0 = top left, 1 = top right, 2 = bottom left, 3 = bottom right)*

  • argument4 = // Distance between text and shadow *

  • argument5 = // Text color*

  • argument6 = // Shadow color *

  • var_pos = argument3*

  • var_spc = argument4*

  • if var_pos = 0*

  • {sx = argument1 - var_spc; sy = argument2 - var_spc} // top left*

  • if var_pos = 1*

  • {sx = argument1 + var_spc; sy = argument2 - var_spc} // top right*

  • if var_pos = 2*

  • {sx = argument1 - var_spc; sy = argument2 + var_spc} // bottom left*

  • if var_pos = 3*

  • {sx = argument1 + var_spc; sy = argument2 + var_spc} // bottom right*

  • draw_set_alpha(0.555)*

  • draw_set_color(argument6)*

  • draw_text(sx, sy, argument0)*

  • draw_set_alpha(0.999)*

  • draw_set_color(argument5)*

  • draw_text(argument1, argument2, argument0);
    }*

Last modified on December 21, 2014 by RAF5UN @rafsun82

over 10 years ago

Creating pause menu:

You can download *.gmk file from - http://www.mediafire.com/download/d2inzv4ilc4v1b6/Project_Pause_Menu.gmk. I will help you if you have any problem to understand this project. But I am telling you now the process.

What is the process

When user press Escape button game will go to pause room. And game will save. When press Resume it load the saved game.

over 10 years ago

Draw disk space:

This code will draw disk space on screen. It must execute from Draw event. Please don't distribute it elsewhere. Just use in your game directly. If you wish you can give creadit.

Just give proper information to the arguments.

Code:

{

  • argument0 = // Drive letter*

  • argument[1,2,3,4] = // x1,y1,x2,y2*

  • argument5 = // total color*

  • argument6 = // used color*

  • argument7 = // outline *

  • *

  • dl = argument0;*

  • du = disk_size(dl) - disk_free(dl);*

  • ds = disk_size(dl);*

  • *

  • x1 = argument1;*

  • y1 = argument2;*

  • x2 = argument3;*

  • y2 = argument4;*

  • *

  • ux = (du(x2-x1))/ds

  • *

  • draw_set_color(argument5)*

  • draw_rectangle(x1,y1,x2,y2,argument7)*

  • *

  • draw_set_color(argument6)*

  • draw_rectangle(x1,y1,x1+ux,y2,argument7)*

}

Last modified on December 26, 2014 by RAF5UN @rafsun82

over 10 years ago

Save Game by Dialog:

It is possible directly using get_save_filename function. But it won't warn if file is already exists. To execute this code you need GM Dialog extension. Don't use it in Step or Draw event.

Please don't distribute it elsewhere. Just use in your game directly. I respect your honesty. If you wish you can give creadit.

Just give proper information to the arguments.

Code:

{

  • argument0 = // caption (string)*

  • argument1 = // filter *(string)

  • argument2 = // ext *(string)

  • wd_save_dialog_set_option(wd_fo_overwriteprompt,1)*

  • wd_save_dialog_set_caption(argument0)*

  • wd_save_dialog_set_filter(argument1)*

  • wd_save_dialog_show()*

  • q = wd_save_dialog_get_file()*

  • *

  • f1 = string_char_at(q, string_length(q)-3)*

  • f2 = string_char_at(q, string_length(q)-2)*

  • f3 = string_char_at(q, string_length(q)-1)*

  • f4 = string_char_at(q, string_length(q))*

  • ff = f1+f2+f3+f4*

  • *

  • *

  • if q != ""*

  • {*

  • if ff = "."+argument2*

  • {*

  • game_save(q)*

  • }*

  • else*

  • {*

  • game_save(q+"."+argument2)*

  • } *

  • }*

}

Last modified on December 26, 2014 by RAF5UN @rafsun82

over 10 years ago

Save Game to Directory:

It will save game to a directory if directory not exists, it will create.

Please don't distribute it elsewhere. Just use in your game directly. I respect your honesty. If you wish you can give creadit.

Just give information to the arguments.

Code:

{

  • argument0 = // directory (string)*

  • argument1 = // filename (string)*

  • dir = argument0*

  • file = argument1*

  • if directory_exists(dir)*

  • game_save(dir+"\"+file);*

  • else*

  • {*

  • directory_create(dir);*

  • game_save(dir+"\"+file);*

  • }*

}

Last modified on December 26, 2014 by RAF5UN @rafsun82

over 10 years ago

Tips 4:

Don't use input and message functions in Step or Draw event. If you do that, press Ctrl+Shift+Esc to open task manager. Go to Processes. End process of the executable.

Last modified on December 26, 2014 by RAF5UN @rafsun82

over 10 years ago

Tips 5:

If you want to get information from the user computer, you can read keys from HKEY_CURRENT_USER\Volatile Environment.

Last modified on December 26, 2014 by RAF5UN @rafsun82

over 10 years ago

Tips 6:

To write or edit registry keys you must run Game Maker or executable as administrator.

Last modified on December 26, 2014 by RAF5UN @rafsun82

over 10 years ago

"December 22, 2014 - 07:38 AM Creating pause menu:

You can download *.gmk file from - http://www.mediafire.com/download/d2inzv4ilc4v1b6/Project_Pause_Menu.gmk. I will help you if you have any problem to understand this project. But I am telling you now the process.

What is the process

When user press Escape button game will go to pause room. And game will save. When press Resume it load the saved game. "

DON'T YOU DARE DO IT THAT WAY.


Set the room to be persistent when pausing then non persistent upon returnin. saving/reloading is sucky in GM. Plus no item menu...

over 10 years ago

@PowerfulKyurem: It will not cause error. If it cause error you can report me. But there is a risk too. If temporary save deleted by mistake game can not load.

Last modified on December 26, 2014 by RAF5UN @rafsun82

over 10 years ago

Sounds and background music does not reload.

over 10 years ago

Reload means? Start from begin?

over 10 years ago

facepalm

When you LOAD the damn save, the sounds DO NOT LOAD. How is that so hard to get through your skull? Are you /dense/?

over 10 years ago

Reply to PowerfulKyurem:

I think it is not possible. But you can wait for others reply. Sorry.

over 10 years ago

You can make objects persistent that stay between the rooms that can keep track of your variables.

over 10 years ago

@Nik :

Thanks Nik for your help. It may help another developers.