### Designing Games with GameMaker

### Real-valued functions

The following functions exist that deal with real numbers.

Returns a random real number between 0 and x. The number is always smaller than x.random(x)

Returns a random real number between x1 (inclusive) and x2 (exclusive).random_range(x1,x2)

Returns a random integer number between 0 and x (inclusive when x is an integer).irandom(x)

Returns a random real number between x1 (inclusive) and x2 (inclusive). Both x1 and x2 must be integer values (otherwise they are rounded down).irandom_range(x1,x2)

Sets the seed (an integer) that is used for the random number generation. Can be used to repeat the same random sequence. (Note though that also some actions and the system itself uses random numbers.)random_set_seed(seed)

Returns the current seed.random_get_seed()

Sets the seed to a random number.randomize()

Returns one of the arguments choosen randomly. The function can have up to 16 arguments.choose(val1,val2,val3,...)

Returns the absolute value of x.abs(x)

Returns the sign of x (-1, 0 or 1).sign(x)

Returns x rounded to the nearest integer.round(x)

Returns the floor of x, that is, x rounded down to an integer.floor(x)

Returns the ceiling of x, that is, x rounded up to an integer.ceil(x)

Returns the fractional part of x, that is, the part behind the decimal dot.frac(x)

Returns the square root of x. x must be non-negative.sqrt(x)

Returns x*x.sqr(x)

Returns x to the power n.power(x,n)

Returns e to the power x.exp(x)

Returns the natural logarithm of x.ln(x)

Returns the log base 2 of x.log2(x)

Returns the log base 10 of x.log10(x)

Returns the log base n of x.logn(n,x)

Returns the sine of x (x in radians).sin(x)

Returns the cosine of x (x in radians).cos(x)

Returns the tangent of x (x in radians).tan(x)

Returns the inverse sine of x.arcsin(x)

Returns the inverse cosine of x.arccos(x)

Returns the inverse tangent of x.arctan(x)

Calculates arctan(Y/X), and returns an angle in the correct quadrant.arctan2(y,x)

Converts degrees to radians.degtorad(x)

Converts radians to degrees.radtodeg(x)

Returns the minimum of the values. The function can have up to 16 arguments. They must either be all real or all strings.min(val1,val2,val3,...)

Returns the maximum of the values. The function can have up to 16 arguments. They must either be all real or all strings.max(val1,val2,val3,...)

Returns the average of the values. The function can have up to 16 arguments. They must all be real values.mean(val1,val2,val3,...)

Returns the median of the values, that is, the middle value. (When the number of arguments is even, the smaller of the two middle values is returned.) The function can have up to 16 arguments. They must all be real values.median(val1,val2,val3,...)

Returns the distance between point (x1,y1) and point (x2,y2).point_distance(x1,y1,x2,y2)

Returns the distance between point (x1,y1,z1) and point (x2,y2,z2).point_distance_3d(x1,y1,z1,x2,y2,z2)

Returns the direction from point (x1,y1) toward point (x2,y2) in degrees.point_direction(x1,y1,x2,y2)

Returns the horizontal x-component of the vector determined by the indicated length and direction.lengthdir_x(len,dir)

Returns the vertical y-component of the vector determined by the indicated length and direction.lengthdir_y(len,dir)

normalizes the vectors (x1,y1) and (x2,y2) to unit vectors, and returns the dot product of these normalized vectors."dot_product(x1,y1,x2,y2)

normalizes the vectors (x1,y1,z1) and (x2,y2,z2) to unit vectors, and returns the dot product of these normalized vectors."dot_product_3d(x1,y1,z1,x2,y2,z2)

Returns whether x is a real value (as opposed to a string).is_real(x)

Returns whether x is a string (as opposed to a real value).is_string(x)

### 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