summaryrefslogtreecommitdiff
path: root/dnglib
diff options
context:
space:
mode:
authorSteph Enders <smenders@gmail.com>2022-12-16 20:12:27 -0500
committerSteph Enders <smenders@gmail.com>2022-12-16 20:12:27 -0500
commitf710faa0cc8862a8367dbbf89bf8c3cd44790b5d (patch)
treee3f2557139989a7cdf89e4f25353235383197c05 /dnglib
parentdd7b7716e1dc1c7e6f13933a89cbbd1116580e2e (diff)
Update enemies list to prevent movement collision
Diffstat (limited to 'dnglib')
-rw-r--r--dnglib/defaults.lua3
1 files changed, 2 insertions, 1 deletions
diff --git a/dnglib/defaults.lua b/dnglib/defaults.lua
index 5b1c7c5..f33e603 100644
--- a/dnglib/defaults.lua
+++ b/dnglib/defaults.lua
@@ -105,7 +105,7 @@ function onUpdate(dt)
map = c_get_map();
assert(type(map) == "table", "map is not a table")
- for _, v in ipairs(enemies) do
+ for i, v in ipairs(enemies) do
local next;
if diff_time >= MOV_TIME then
next = algs.pathfind(v, player, enemies, treasures, map)
@@ -118,6 +118,7 @@ function onUpdate(dt)
if new_pos.x == player.x and new_pos.y == player.y then
c_trigger_loss()
end
+ enemies[i] = new_pos -- update new position for pathfinding
end
treasures = c_get_treasures()
assert(type(treasures) == "table", "treasures is not a table")