From f710faa0cc8862a8367dbbf89bf8c3cd44790b5d Mon Sep 17 00:00:00 2001 From: Steph Enders Date: Fri, 16 Dec 2022 20:12:27 -0500 Subject: Update enemies list to prevent movement collision --- dnglib/defaults.lua | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'dnglib/defaults.lua') 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") -- cgit v1.2.3-54-g00ecf