summaryrefslogtreecommitdiff
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
parentdd7b7716e1dc1c7e6f13933a89cbbd1116580e2e (diff)
Update enemies list to prevent movement collision
-rw-r--r--dnglib/defaults.lua3
-rw-r--r--maps/lvl3/dng.map40
-rw-r--r--maps/lvl4/dng.map2
3 files changed, 23 insertions, 22 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")
diff --git a/maps/lvl3/dng.map b/maps/lvl3/dng.map
index 23a654e..d250f9f 100644
--- a/maps/lvl3/dng.map
+++ b/maps/lvl3/dng.map
@@ -1,23 +1,23 @@
w w w w w w w w w w w w w w w w w w w w w
w 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 w
-w 0 t t t t t t t t t t t t t t t t t 0 w
-w p t 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 t 0 w
-w 0 t e 0 0 0 0 0 0 0 0 0 0 0 0 0 0 t 0 w
-w 0 t 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 t 0 w
-w 0 t 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 t 0 w
-w 0 t 0 0 0 0 0 0 0 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t 0 0 0 0 0 w 0 0 0 0 0 0 0 w 0 w
+w 0 w 0 0 0 0 0 0 0 w 0 0 0 0 0 0 0 w 0 w
+w 0 w 0 0 0 0 0 0 0 w 0 0 0 0 0 0 0 w 0 w
+w 0 w 0 t 0 0 0 0 0 w 0 0 0 0 t 0 0 w 0 w
+w 0 w 0 0 0 0 0 0 0 w 0 0 0 0 0 0 0 w 0 w
+w 0 w t t t t t t t w t t t t t t t t 0 w
+w 0 w w w w w w w w t w w w w w w w 0 0 w
+w 0 t 0 0 0 0 0 0 0 t 0 0 0 0 0 0 0 0 0 w
+w 0 t 0 0 0 0 0 0 0 w 0 0 0 0 0 0 0 0 0 w
w w w w w w w w w w w w w w w w w w w w w
diff --git a/maps/lvl4/dng.map b/maps/lvl4/dng.map
index 65617b0..aaed224 100644
--- a/maps/lvl4/dng.map
+++ b/maps/lvl4/dng.map
@@ -3,7 +3,7 @@ w 0 0 0 0 0 0 0 0 w
w 0 t t t t t t 0 w
w 0 t 0 0 0 0 t 0 w
w p t 0 t e 0 t 0 w
-w 0 t 0 t 0 0 t 0 w
+w 0 t 0 t e 0 t 0 w
w 0 t 0 0 0 0 t 0 w
w 0 t t t t t t 0 w
w 0 0 0 0 0 0 0 0 w