Skip to content

Commit

Permalink
impl: see_angle_object - mouse
Browse files Browse the repository at this point in the history
  • Loading branch information
gnlow committed Dec 29, 2023
1 parent bd26277 commit fb8305d
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions src/Entry.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit fb8305d

Please sign in to comment.