Skip to content

point_distance

drewmccluskey edited this page Jan 23, 2019 · 1 revision

point_distance

returns the pixel distance between two points based upon either two vector points or 2 sets of X-Y input points.

Syntax:

point_distance(p1, p2) //Vector
point_distance(x1, y1, x2, y2) //X-Y

Vector

Argument Description
Vector2 p1 First position
Vector2 p2 Second position

X-Y

Argument Description
double x1 First x position
double y1 First y position
double x2 Second x position
double y2 Second y position

Returns: double

Description:

This function will return the distance from the first point to the second point coordinates. It is useful for programming AI as well as enabling effects or spring traps.

Vector Example:

var GroundDistance = point_distance(Position, new Vector2(Position.x,room_height-64));

Above code will set var GroundDistance to the current distance of the player to the ground by vector.

X-Y Example 2:

var GroundDistance = point_distance(x,y,x,room_height-64);

Above code will set var GroundDistance to the current distance of the player to the ground by X-Y positions.

Back to Vectors

Clone this wiki locally