Arrays can be mixed-type and nested.
// 1D Array inventory = ["sword", "shield", "potion"];// 2D Array (Grid) map = [ [1, 1, 0], [1, 0, 1], [0, 0, 1] ];
// Accessing value = map[1][2]; // Returns 1
// Direct coordinates x += 5; // Move right y -= 4; // Move up// Speed and direction (built-in variables) speed = 4; direction = point_direction(x, y, mouse_x, mouse_y); // Move toward mouse gamemaker studio 2 gml
// Motion add motion_add(angle, acceleration); friction = 0.1; // Slow down over time
If you are migrating from Drag-and-Drop, here is the bare minimum you need to write code.
Memorize these. They are the bread and butter of GMS2. Arrays can be mixed-type and nested
1. Incredibly Easy to Learn
GML strips away boilerplate. This code moves a player left:
if (keyboard_check(vk_left)) x -= 4;
No classes, no main loops, no imports. It’s perfect for beginners or artists-turned-coders.
2. Surprisingly Fast for 2D Games
Under the hood, GML compiles to native machine code (via YoYo Compiler 2). You can spawn thousands of objects without frame drops. For 2D platformers, shooters, RPGs, or puzzle games, performance is rarely an issue.
3. Deep Engine Integration
GML seamlessly controls every part of GameMaker: // Direct coordinates x += 5; // Move
4. Quick Prototyping
You can go from an idea to a playable .exe in an afternoon. The iterative workflow (edit code → press play → test) is nearly instant.
5. Cross-Platform Export (with caveats)
GML code runs on Windows, macOS, Linux, HTML5, iOS, Android, and consoles (via partners). No massive rewrites.
// Step Event var key_left = keyboard_check(vk_left); var key_right = keyboard_check(vk_right); var key_jump = keyboard_check_pressed(vk_space); // true only for one frame
// Custom keys (ASCII) var key_attack = keyboard_check(ord('X'));