GML uses standard if , else if , and else statements, alongside switch cases for decision-making logic.
Modern GML uses and json_parse with structs.
Runs when the instance is deleted via code. Used for cleanup (e.g., spawning an explosion effect). 3. GML Fundamentals: Syntax and Core Concepts gamemaker studio 2 gml
You do not need to declare variable types (int, string, bool). GML handles dynamic typing.
You can define a custom function anywhere using the function keyword: GML uses standard if , else if ,
hsp = 0; // Current horizontal speed vsp = 0; // Current vertical speed grv = 0.3; // Gravity strength walk_speed = 4; // Max walk speed jump_speed = 7; // Jump power Use code with caution. 6. Data Structures in GML (DS Lists, Maps, Grids)
By default, instances draw their sprite automatically. To customize, use the event. Used for cleanup (e
In this example, we use the room_goto function to switch to the room_menu room.
GML does not run from a main() function. Instead, code lives inside attached to Objects .
GML is a specialized scripting language designed specifically for game development. It is often described as a blend of C, C++, and JavaScript, making it accessible for beginners while providing the depth required by professionals. The engine offers two ways to use GML:
You can create anonymous functions and assign them to a variable. This is powerful for callbacks and event handling.