GML, short for GameMaker Language, was created in 1999 by Mark Overmars and later maintained by YoYo Games as part of the GameMaker Studio environment. GML is a high-level scripting language designed specifically for 2D and 3D game development. It is used within the GameMaker platform to control game logic, object behavior, animations, collisions, and input handling. Developers can access GML by downloading GameMaker Studio from the official site: GameMaker Studio, which provides the editor, runtime, libraries, and comprehensive documentation for Windows and macOS.
GML exists to simplify game development by providing a language that is easy to learn for beginners yet powerful enough for complex projects. Its design philosophy emphasizes readability, rapid iteration, and close integration with the GameMaker runtime. By offering a scripting layer that directly interacts with game objects and assets, GML solves the problem of manually managing game loops, collision detection, and animation updates, enabling developers to focus on gameplay design and rapid prototyping.
GML: Variables and Data Types
GML uses dynamically typed variables to store numbers, strings, and object references.
var playerName = "Hero";
var score = 0;
var isAlive = true;
show_debug_message("Player: " + playerName + ", Score: " + string(score));Variables can be declared with var to limit scope. Dynamic typing allows quick experimentation and flexible gameplay logic, conceptually similar to scripting in Lua or Python.
GML: Control Flow and Loops
GML supports traditional control structures such as if, for, and while to manage execution flow.
for (var i = 0; i < 10; i++) {
if (i mod 2 == 0) {
show_debug_message(i + " is even");
} else {
show_debug_message(i + " is odd");
}
}These structures allow developers to handle repeated actions and conditional logic in games. This approach is conceptually similar to JavaScript loops and Python control flow constructs.
GML: Object-Oriented Event System
GML integrates tightly with GameMaker’s object-event system, where scripts respond to events such as collisions, key presses, and timers.
// Inside an object's Step Event
if (keyboard_check(vk_left)) {
x -= 4;
}
if (keyboard_check(vk_right)) {
x += 4;
}Scripts run within object events, simplifying interactive gameplay development. This is conceptually similar to event-driven programming in JavaScript and C# Unity scripts.
GML: Functions and Scripts
GML allows creation of reusable scripts and user-defined functions to modularize game logic.
function addScore(points) {
score += points;
show_debug_message("New Score: " + string(score));
}
addScore(100);Functions enable encapsulation of common behaviors and logic, improving code clarity and maintainability, conceptually similar to scripting in Lua or Python.
GML: Arrays and Data Structures
GML provides arrays and data structures such as lists, maps, and grids to manage collections of objects and values.
var enemies = [];
array_push(enemies, obj_enemy);
array_push(enemies, obj_boss);
for (var i = 0; i < array_length(enemies); i++) {
show_debug_message("Enemy: " + string(enemies[i]));
}Arrays and collections allow organized storage of multiple entities. This approach is conceptually similar to Lua tables and Python lists and dictionaries.
GML is used in indie game development, rapid prototyping, and educational games. Its simplicity, close integration with GameMaker Studio, and event-driven model make it ideal for developers creating interactive 2D and 3D games quickly. When combined with Lua, Python, and JavaScript, GML provides a fast, approachable, and productive environment for game development, enabling robust gameplay and user interactions with minimal boilerplate.