From cf1ce9c40716da7883cde90633453aaa82fa9a45 Mon Sep 17 00:00:00 2001 From: Eltrac Date: Thu, 13 Mar 2025 20:15:40 +0800 Subject: feat: player now can click right to punch mobs --- objects/Enemy.lua | 15 +-------------- 1 file changed, 1 insertion(+), 14 deletions(-) (limited to 'objects/Enemy.lua') 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) -- cgit v1.2.3