The distance between x_1 and x_2 is computed by line-length(x1, x2). The distance between y_1 and y_2 is computed by line-length(y1, y2). Below is the equation to compute the hypotenuse of a right triangle with those amount for legs:
√( line\mbox-length(x_2, x_1)^2 + line\mbox-length(y_2, y_1)^2 )
Suppose your player is at (0, 2) and a character is at (4, 5). What is the distance between them? With your pencil, label which numbers represent x_1, y_1, x_2 and y_2. The equation to compute the distance between these points is:
√( line\mbox-length(4, 0)^2 + line\mbox-length(5, 2)^2 )
1. Translate the expression above, for (0,2) and (4,5) into a Circle of Evaluation below.
2. Convert the Circle of Evaluation to Code below.
These materials were developed partly through support of the National Science Foundation, (awards 1042210, 1535276, 1648684, and 1738598). Bootstrap by the Bootstrap Community is licensed under a Creative Commons 4.0 Unported License. This license does not grant permission to run training or professional development. Offering training or professional development with materials substantially derived from Bootstrap must be approved in writing by a Bootstrap Director. Permissions beyond the scope of this license, such as to run training, may be available by contacting contact@BootstrapWorld.org.