summaryrefslogtreecommitdiffstats
path: root/HexBoard.gd
diff options
context:
space:
mode:
Diffstat (limited to 'HexBoard.gd')
-rw-r--r--HexBoard.gd8
1 files changed, 5 insertions, 3 deletions
diff --git a/HexBoard.gd b/HexBoard.gd
index 993776d..0bc6fa1 100644
--- a/HexBoard.gd
+++ b/HexBoard.gd
@@ -184,11 +184,13 @@ func distance(p0 : Vector2, p1 : Vector2, euclidean : bool = true) -> float:
var fdy : float = dy * 0.86602
return sqrt((fdx * fdx) + (fdy * fdy))
else:
- var dz : float = abs((p0.x - p0.y) - (p1.x - p1.y))
+ dx = int(abs(dx))
+ dy = int(abs(dy))
+ var dz : float = abs(p1.x - p0.x - p1.y + p0.y)
if dx > dy:
- if dx > dz : return abs(dx)
+ if dx > dz: return float(dx)
else:
- if dy > dz: return abs(dy)
+ if dy > dz: return float(dy)
return dz
# http://zvold.blogspot.com/2010/01/bresenhams-line-drawing-algorithm-on_26.html