Game Maker 8 Tutorial: Math Functions

James Cloud
It would be safe to say that pretty much all the commercial games created make use of some form of mathematical functions. From generating random numbers, calculating 3d trigonometry functions, to simple addition and subtraction, multiplication and division, this tutorial will guide you in the math function given in Game Maker 8 GML coding language.

Step One - Game Maker 8 Math Functions

This section of the tutorial will serve as a reference to the math functions built into Game Maker 8's GML Language. It will also include a description of the functionality of each command. Where you see the '#' symbol you should replace it with your desired numerical value as a parameter.

Game Maker 8 Math Functions:

Random(#) - This command will generate a random number smaller than the given parameter.

Random_Range(#, #) - Another random generation function. This one will return a number greater than the first parameter and smaller than the second.

Abs(#) - Give the absolute number of the given parameter.

Round(#) - Retrieves the rounded form of a number closest to the given parameter.

Sqrt(#) - As can be easily deduced, this function returns the square root of the number given.

Sin(#) - Retrieves the sine value of the parameter.
Cos(#) - Gets the cosine of the given parameter.
Tan(#) - Finds the tangent of the numerical parameter.
ArcSin(#) - Gets the arc( or inverse) sine of the supplied parameter.
ArcCos(#) - Retrieves the arc( or inverse) cosine of the parameter.
ArcTan(#) - Finds the arc( or inverse) tangent of #.

DegToRad(#) - Changes the value of the given number from degrees to radians.
RadToDeg(#) - Changes the value of the given number from radians to degrees.

Mean(#, #, #, etc.) - Finds the mean( or average) of the given numbers.
Median(#, #, #, etc.) - Finds the middle value of the given parameter values.

If you receive an error with the listed function make sure to enter them in lower case and supply the correct parameter.

Conclusion

Above are highlighted some of Game Maker's most used mathematical abilities. For a more comprehensive list, with more information and usage examples, please check out the Game Maker 8 manual, included with your copy of Game Maker.

NOTE:

It is typical in the Game Maker community to ask for credit, however these scripts are provided absolutely free and require no credit what so ever.

Published by James Cloud

I like to program and do basically anything that has to do with technology and computers.  View profile

To comment, please sign in to your Yahoo! account, or sign up for a new account.