GameMaker:Studio has its own proprietary programming language called the GameMaker Language (abbreviated to GML).
The GameMaker:Studio programming language, GML, gives you much more flexibility and control than the standard actions that are available through the Drag'n'Drop interface. There are a number of different places where you can use this language to create and control your game :
•Scripts. A script is a (usually) short snippet of code in GML that you write to create your own functions.
•Events. You can use code within object events to control the behaviour and interactions of instances of those objects. You can even mix Drag'n'Drop with code!
•Room Creation Code. Each room can have a special "create event" specific for that room. Here you can add the code you need and it will be run when every time the room is entered.
•Instance Creation Code As well as the code you insert into the events of an object, you can also add code to individual instances when you place them in the room. This code will either run after (default) or before the create event of the object (this can be set in the Global Game Settings) and is specific to the instance that you add it to. So you can have four instances of the same object, yet each one can be made to have some different properties thanks to this code.
In this section we will describe the basic structure of GML functions and how they are used to create your own programs and generally control your games. Please note that before programing in GameMaker:Studio there are a few conventions that you should follow! First of all, for all your resources (sprites, objects, sounds, etc...) you must use names that start with a letter and only consist of letters, digits and the underscore '_' symbol (for example "spr_Fish" is acceptable but not "spr Fish" or "6fish") otherwise you will not be able to refer to them with any GML functions. Also, make sure all resources have different names (there is a function in the Scripts section of the main IDE that can check this for you), and do not name resources self, other, global, or all because these have special meaning in the language.
Information on the GML language can be found in the following pages:
◦Variables and Variable Scope
◦Addressing Variables in Other Instances
◦The "If" Statement
◦The "Repeat" Statement
◦The "While" Statement
◦The "Do" Statement
◦The "For" Statement
◦The "Switch" Statement
◦The "Break" Statement
◦The "Continue" Statement
◦The "Exit" Statement
◦The "With" Construction
◦Comments in Code
Back : Reference