No Revisions Have Been Made To This Page
Can you suggest an edit for this page? Click Here
This section goes over the structure of the manual as well as an introduction to the GML Language and it's syntax.
This section introduces the types of numbers and basic variables in GML and their related functions.
The section covers the various assets involved in GameMaker: Studio and their related functions as well as Handling Input.
This section contains information about 2D Drawing, 3D Drawing, Shaders, Surfaces, and Views.
This section goes further into detail about the GML Language and more advanced functions like Networking, Data Structures, Physics, and more.
This section is a reference to the Platform Specific functions and methods available to you as well as integrating your game with Third Party Applications.
This section contains Debugging, Miscellaneous, and Obsolete function reference.
View :
Original

Community
Revision

Source
GML Code Example
round(n);
Argument  Description 

n  The number to round. 
Returns: Integer
Just as it says, round() takes a real number and rounds
it up or down to the nearest integer. In the special case where the
number supplied is exactly a halfinteger (1.5, 17.5, 2.5, etc),
the number will be rounded to the nearest even value, for
example, 2.5 would be rounded to 2, while 3.5 will be rounded to 4.
This type of rounding is called bankers rounding and over
large numbers of iterations or when using floating point maths, it
gives a statistically better rounding than the more traditional
"round up if over .5 and round down otherwise" approach.
What this means is that if the fraction of a value is 0.5, then the
rounded result is the even integer nearest to the input
value. So, for example, 23.5 becomes 24, as does 24.5, while 23.5
becomes 24, as does 24.5. This method treats positive and
negative values symmetrically, so is therefore free of sign bias,
and, more importantly, for reasonable distributions of values, the
expected (average) value of the rounded numbers is the same as that
of the original numbers.
GML Code Example
score += round(hp / 5);
The above code will add a rounded integer onto the score value.
Can you suggest an edit for this page? Click Here
Does this page need better examples? Be the first to Submit
Is this page unclear or not descriptive enough? Suggest an edit to the page and with enough upvotes your changes will be made.
Do you have a question about this page? Ask it Here
To use this feature sign in with your Reddit account.