Game Development Reference
In-Depth Information
Macros
In other programming languages, you may have heard of or even used a data type called a
constant . Macros are GameMaker's version of a constant data type.
A macro, or constant, is a data type that never changes and often stores a value. These val-
ues have a global scope, which means they can be accessed by any instance within a game.
They are commonly used to easily define things such as weapon types using numbers in-
stead of strings.
A handgun could be considered gun type 0. A machine gun could be gun type 1. Instead of
checking a string to see what gun type is currently being held by the character in a game,
you can check what gun they are holding based on the name of the macro variable.
Here is an example in GML code:
HANDGUN and MACHINEGUN are macro variables. HANDGUN is equal to 0 and
MACHINEGUN is equal to 1 . Without the macros, that code would look like the following:
Search WWH ::




Custom Search