AnatomyOf

Anatomy of a GML file

example.gml
1/// @description obj_player :: Step Event
2
3#macro WALK_SPEED 4
4
5// Local: gone the moment this event ends.
6var _dx = keyboard_check(vk_right) - keyboard_check(vk_left);
7
8// x is a built-in instance variable, so assigning to it moves you.
9x += _dx * WALK_SPEED;
10
11if (place_meeting(x, y, obj_wall)) {
12 x -= _dx * WALK_SPEED; // a collision engine, shipped as-is
13}
14
15if (hp <= 0) {
16 show_debug_message("Player down at " + string(x) + ", " + string(y));
17 instance_destroy();
18}
GML is GameMaker's built-in scripting language. A .gml file is either one event of one object or a script of reusable functions, and since GameMaker 2.3 a single script file can hold as many functions, constructors, and macros as you want.