-
-
Notifications
You must be signed in to change notification settings - Fork 18
point_distance
drewmccluskey edited this page Jan 23, 2019
·
1 revision
returns the pixel distance between two points based upon either two vector points or 2 sets of X-Y input points.
point_distance(p1, p2) //Vector
point_distance(x1, y1, x2, y2) //X-Y
Argument | Description |
---|---|
Vector2 p1 |
First position |
Vector2 p2 |
Second position |
Argument | Description |
---|---|
double x1 |
First x position |
double y1 |
First y position |
double x2 |
Second x position |
double y2 |
Second y position |
Returns: double
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.
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.
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