The distance between 𝑥1 and 𝑥2 is computed by (line-length x2 x1). The distance between 𝑦2 and 𝑦1 is computed by (line-length y2 y1). Below is the equation to compute the hypotenuse of a right triangle with legs the lengths of those distances:

line-length(𝑥2, 𝑥1)2 + line-length(𝑦2, 𝑦1)2

Suppose your player is at (0, 2) and a character is at (4, 5). What is the distance between them?

1. Identify the values of 𝑥1, 𝑦1, 𝑥2, and 𝑦2

𝑥1 𝑦1 𝑥2 𝑦2

(x-value of 1st point)

(y-value of 1st point)

(x-value of 2nd point)

(y-value of 2nd point)

The equation to compute the distance between these points is:

line-length(4, 0)2 + line-length(5, 2)2

2. Translate the expression above, for (0,2) and (4,5) into a Circle of Evaluation below.

Hint: In our programming language sqr is used for 𝑥2 and sqrt is used for 𝑥

3. Convert the Circle of Evaluation to Code below.

These materials were developed partly through support of the National Science Foundation, (awards 1042210, 1535276, 1648684, 1738598, 2031479, and 1501927). CCbadge 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.