summaryrefslogtreecommitdiff
path: root/objects/Enemy.lua
diff options
context:
space:
mode:
authorEltrac <hi@guhub.cn>2025-03-13 20:15:40 +0800
committerEltrac <hi@guhub.cn>2025-03-13 20:15:40 +0800
commitcf1ce9c40716da7883cde90633453aaa82fa9a45 (patch)
treece0edefe4af7cbbd0373f9a4e99aefaa7a0a79cb /objects/Enemy.lua
parentc80deca77394890e4083724b7d29fea4e54b6be4 (diff)
feat: player now can click right to punch mobs
Diffstat (limited to 'objects/Enemy.lua')
-rw-r--r--objects/Enemy.lua15
1 files changed, 1 insertions, 14 deletions
diff --git a/objects/Enemy.lua b/objects/Enemy.lua
index 5ee8793..64dea31 100644
--- a/objects/Enemy.lua
+++ b/objects/Enemy.lua
@@ -81,20 +81,7 @@ end
function Enemy:facing()
local dx = self.x - G.player.x
local dy = self.y - G.player.y
- local angle = math.atan2(dy, dx)
-
- local dir
- if angle >= -math.pi / 4 and angle < math.pi / 4 then
- dir = Direction.LEFT
- elseif angle >= math.pi / 4 and angle < 3 * math.pi / 4 then
- dir = Direction.UP
- elseif angle >= -3 * math.pi / 4 and angle < -math.pi / 4 then
- dir = Direction.DOWN
- else
- dir = Direction.RIGHT
- end
-
- return dir
+ return utils.angleToDirection(utils.atan2(dy, dx))
end
function Enemy:takeDamage(damage)