summaryrefslogtreecommitdiff
path: root/objects/Enemy.lua
diff options
context:
space:
mode:
authorEltrac <hi@guhub.cn>2025-03-06 23:07:16 +0800
committerEltrac <hi@guhub.cn>2025-03-06 23:07:16 +0800
commit41fef59b951d8a43d4f4c32b71fe93782f5d607f (patch)
tree333c854d4b0367d51320bf91faaba9b035258c30 /objects/Enemy.lua
parent4be7c993013fc91d0956454149c769abdee68f81 (diff)
fix: delta becomes a boolean value in some case
Diffstat (limited to 'objects/Enemy.lua')
-rw-r--r--objects/Enemy.lua2
1 files changed, 1 insertions, 1 deletions
diff --git a/objects/Enemy.lua b/objects/Enemy.lua
index 017bc06..429b79a 100644
--- a/objects/Enemy.lua
+++ b/objects/Enemy.lua
@@ -52,7 +52,7 @@ function Enemy:moveTo(x, y, dt)
local function getDelta(axis, destination, direction)
-- delta is either +1 or -1, represents the direction
- local delta = (self[axis] < destination and 1) or (self[axis] > destination and -1)
+ local delta = (self[axis] < destination and 1) or (self[axis] > destination and -1) or 0
-- check if the movement is blocked, if so delta is 0, meaning no movement
local isBlocked = utils.isBlocked(self.body, self.x, self.y, direction, axis, dv*delta)