API Reference › Math › Math.dist
method

Math.dist

Math.dist(x0, y0, x1, y1) -> fixed

Returns the straight-line distance between (x0, y0) and (x1, y1) — sqrt(dx*dx + dy*dy) in fixed-point. Use it for proximity and range checks. When you only need to compare distances (which is nearer? within radius?), prefer Math.dist2, which skips the square root.

Example

program Demo {
  handler Step phase Update {
    if Math.dist(px, py, ex, ey) < attack_range { strike() }
  }
}
← All symbols