From fb8305dcaa82353a2e0855faf43b53795b34fc92 Mon Sep 17 00:00:00 2001 From: Gnlow Date: Fri, 29 Dec 2023 19:48:14 +0900 Subject: [PATCH] impl: see_angle_object - mouse --- src/Entry.ts | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/Entry.ts b/src/Entry.ts index 234cd77..6234a28 100644 --- a/src/Entry.ts +++ b/src/Entry.ts @@ -389,9 +389,12 @@ export class Entry { obj.direction = angle } see_angle_object(objId: string, obj: EntryContainer) { - if (objId == "mouse") - throw new Error("Unimplemented: locate to mouse") - const target = this.objects[objId] + let target: { x: number, y: number } + if (objId == "mouse") { + target = this.mouse + } else { + target = this.objects[objId] + } const dx = target.x - obj.x const dy = target.y - obj.y obj.rotation = - toDegrees(dy / dx) - obj.direction + (dx > 0 ? 90 : 270)