From e30b2a81b48f5e86474aa2c38d7034d63c0b7c4e Mon Sep 17 00:00:00 2001 From: Gene Pasquet Date: Sun, 18 May 2025 09:18:07 +0100 Subject: Enemies sort of working --- src/macroknight/utils.hy | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'src/macroknight/utils.hy') diff --git a/src/macroknight/utils.hy b/src/macroknight/utils.hy index dde8d2e..5de8887 100644 --- a/src/macroknight/utils.hy +++ b/src/macroknight/utils.hy @@ -1,4 +1,5 @@ -(import enum [Enum]) +(import enum [Enum] + math [sqrt]) (defclass Direction [Enum] (setv UP "UP") @@ -44,3 +45,7 @@ (defn sub-points [point1 point2] #((- (get point2 0) (get point1 0)) (- (get point2 1) (get point2 1)))) + +(defn distance [point1 point2] + (sqrt (+ (** (- (get point1 0) (get point2 0)) 2) + (** (- (get point1 1) (get point2 1)) 2)))) -- cgit v1.2.3