lengthdir_y - hpgDesigns/hpgdesigns-dev.io GitHub Wiki

Notation

Description

lengthdir_xy.svg and lengthdir_y.]] Gives the vertical component of a vector with the given length and direction; this can be thought of as the terminal y-coordinate of a vector at (0,0). It may help to think of the input as the depiction of a right triangle, where the length is the hypotenuse and the direction is the angle.

Bear in mind that the return value is only the vertical component of the input vector; you will generally want to add this value to a coordinate.

This function is generally used with its sister function lengthdir_x().

Parameters

  • len: length of the vector; the hypotenuse of the right triangle, or the distance between (0,0) and the desired point
  • dir: direction in degrees of the vector; the angle of the right triangle, or the direction from (0,0) to the desired point

Return Values

double: Returns the vertical component of the given vector.

Example Call

// Create a circle of ten coin objects 64px from this object
for (int dir = 0; dir < 360; dir += 36) // Loop through all directions from 0 to 360 in increments of 36, so 10 directions
{
  instance_create(x + lengthdir_x(64, dir), y + lengthdir_y(64, dir), obj_coin); // Create a coin 64px out in each direction
}

NOTOC

Category:Function:Real

⚠️ **GitHub.com Fallback** ⚠️