GML is dynamically typed, meaning you don’t need to declare int or string .
GML code does not run in a vacuum. It is executed inside tied to Objects. The most critical events are:
// Get input var left = keyboard_check(vk_left); var right = keyboard_check(vk_right); var up = keyboard_check(vk_up); var down = keyboard_check(vk_down);
// In obj_enemy_parent (Create Event) hp = 50; speed = 2; gamemaker studio 2 gml
While the visual system is great for learning logic, GML is more efficient for long-term development. Code is faster to write, easier to debug, and much simpler to share with team members. As your project grows, managing hundreds of visual blocks becomes cumbersome, whereas a few lines of GML can accomplish the same task with clarity. Intermediate Power: Scripts and Functions
Millions of people use GML, so it is easy to find help online. Core Concepts of GML
GML is structured around , instances , and events . When you write GML code, you are almost always placing it within a specific event of an object. GML is dynamically typed, meaning you don’t need
Let's put it all together into a simple player movement script.
Variables and ScopeGML uses three main types of variables. Local variables (using the keyword 'var') exist only for the duration of a single script or event. Instance variables belong to a specific object and persist as long as that object exists. Global variables can be accessed by any object in the game at any time, which is ideal for tracking high scores or game settings.
// Player stats hp_max = 100; hp = hp_max; move_speed = 4; sprite = spr_player_idle; The most critical events are: // Get input
GML looks up variables slowly. Use var for temporary variables.
Do not place heavy calculations in the Step event if they don't need to run every frame.
// BAD: O(n^2) complexity with (obj_enemy) with (obj_bullet) // collision check
GameMaker Language (GML) is an imperative, dynamically typed programming language Wikipedia . It is designed to allow developers to create complex game logic without the overhead of lower-level languages like C++.
Introduced in major GMS2 updates, structs allow you to create custom, lightweight data structures without the overhead of a full object. You can also assign functions (methods) to variables.