From 58eb7ceccc5c67321476ea801ea6f3f559428f30 Mon Sep 17 00:00:00 2001 From: Gnlow Date: Fri, 29 Dec 2023 20:14:25 +0900 Subject: [PATCH] impl: distance_something --- src/Entry.ts | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/Entry.ts b/src/Entry.ts index 6234a28..52e8a35 100644 --- a/src/Entry.ts +++ b/src/Entry.ts @@ -870,6 +870,19 @@ export class Entry { return new Date().getSeconds() } } + distance_something(targetId: string, obj: EntryContainer) { + let target: { x: number, y: number } + if (targetId == "mouse") { + target = this.mouse + } else { + target = this.objects[targetId] + } + const dx = target.x - obj.x + const dy = target.y - obj.y + return Math.sqrt( + dx**2 + dy**2 + ) + } length_of_string(str: string) { return str.length }