Home | Customize | Blog | Extras | Log In | Info
Manual | D&D icons | GML Parser | Archive | Iso City
Username: Password:  
About | Features | Directory | Banners | Contact

Designing Games with Game Maker
Designing Games with Game Maker

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. 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
As values you can use numbers, variables, or functions that return a value. Sub-expressions can be placed between brackets. All operators work for real values. Comparisons also work for strings and + concatenates strings. (Please note that, contrary to certain languages, both arguments to a Boolean operation are always computed, even when the first argument already determines the outcome.)

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);
}

Search Search


Alternative versions Alternative versions

You can also read this manual on one single long page (± 1.5 mb)

Also available in: Dutch French German

ZIP Download helpfile

Advertisement Advertisement

Game Maker Manual