Designing Games with GameMaker
Expressions
Expressions can be real numbers (e.g. 3.4), hexadecimal numbers, starting with a $ sign (e.g. $00FFAA), strings between single or double quotes (e.g. 'hello' or “hello”) or more complicated expressions. (Note that strings can run over multiple lines!) For expressions, the following binary operators exist (in order of priority):- && || ^^: combine Boolean values (&& = and, || = or, ^^ = xor)
- < <= == != > >=: comparisons, result in true (1) or false (0)
- | & ^: bitwise operators (| = bitwise or, & = bitwise and, ^ = bitwise xor)
- << >>: bitwise operators (<< = shift left, > > = shift right)
- + -: addition, subtraction
- * / div mod: multiplication, division, integer division, and modulo
Note that value of x div y is the value of x/y rounded in the direction of zero to the nearest integer. The mod operator returns the remainder obtained by dividing its operands. In other words, x mod y = x - (x div y) * y. Also, the following unary operators exist:
- !: not, turns true into false and false into true
- -: negates the next value
- ~: negates the next value bitwise
Example
Here is an example with some assignments.
{ x = 23; color = $FFAA00; str = 'hello world'; y += 5; x *= y; x = y << 2; x = 23*((2+4) / sin(y)); str = 'hello' + " world"; b = (x < 5) && !(x==2 || x==4); }
« Assignments | Extra variables »
Alternative versions
You can also read this manual on one single long page (± 1.5 mb)
Also available in:
Download helpfile
Also available in:
Download helpfile