diff options
author | Steph Enders <smenders@gmail.com> | 2022-12-16 20:12:27 -0500 |
---|---|---|
committer | Steph Enders <smenders@gmail.com> | 2022-12-16 20:12:27 -0500 |
commit | f710faa0cc8862a8367dbbf89bf8c3cd44790b5d (patch) | |
tree | e3f2557139989a7cdf89e4f25353235383197c05 /dnglib | |
parent | dd7b7716e1dc1c7e6f13933a89cbbd1116580e2e (diff) |
Update enemies list to prevent movement collision
Diffstat (limited to 'dnglib')
-rw-r--r-- | dnglib/defaults.lua | 3 |
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") |