round function in GameMaker is used to round a floating-point number to the nearest whole number. The way it works is by checking the decimal part of the number; if it's 0.5 or higher, the function rounds up, and if it's lower than 0.5, it rounds down.
Here's an example of how you can use the
In this case,
roundedNumber would contain the value
2.7 is closer to
3 than to
It's important to note that
round differs from
floor always rounds down to the nearest whole number,
ceil always rounds up to the nearest whole number.
Understanding these differences is crucial when performing various mathematical operations in GameMaker, especially when dealing with graphics or logic that depends on integer values.