point_in_circle


Description

When using this function, you define a circular area and GameMaker Studio 2 will work out whether the given point falls within its bounds or not. If the point falls within the defined circle the function will return true otherwise the function will return false.


Syntax:

point_in_circle(px, py, x1, y1, rad);

Argument Description
px The x coordinate of the point to check.
py The y coordinate of the point to check.
x1 The x coordinate of the circle centre.
y1 The y coordinate of the circle centre.
rad The radius of the circle.


Returns:

Boolean


Example:

if point_in_circle(mouse_x, mouse_y, x, y, 16)
   {
   over = true;
   }
else
   {
   over = false;
   }

The above code uses the point_in_circle function to check if the mouse position falls within the defined circular area, setting the variable "over" to true if it does, or false otherwise.