point_in_circle

Checks to see whether a given point falls within the defined circular area.

Syntax:

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


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.
r The radius of the circle.


Returns: Boolean


Description

When using this function, you define a circular area and GameMaker: Studio 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.


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.


Back: Collision Checking
Next: rectangle_in_rectangle