aboutsummaryrefslogtreecommitdiff
path: root/tools/map.py
diff options
context:
space:
mode:
authorJuan J. Martinez <jjm@usebox.net>2023-07-27 09:37:53 +0100
committerJuan J. Martinez <jjm@usebox.net>2023-07-27 09:37:53 +0100
commitcdfbad1df2d28b8efb2f7fae5850df56ecf6f8ff (patch)
treeb4117136464e47d3873765093299fe0a027c0075 /tools/map.py
parent6229bb89249c5b842a36b0b7982cc25b47bbafdf (diff)
downloadgold-mine-run-cdfbad1df2d28b8efb2f7fae5850df56ecf6f8ff.tar.gz
gold-mine-run-cdfbad1df2d28b8efb2f7fae5850df56ecf6f8ff.zip
Properly count entities and sure we support enough
This accounts: - entities on the map - entities that will be spawn to unlock doors - the time monster
Diffstat (limited to 'tools/map.py')
-rwxr-xr-xtools/map.py9
1 files changed, 7 insertions, 2 deletions
diff --git a/tools/map.py b/tools/map.py
index c959c50..8ead427 100755
--- a/tools/map.py
+++ b/tools/map.py
@@ -23,6 +23,9 @@ entity_types = (
"SilverKey",
)
+# these tiles are part of a door and will use an entity to unlock
+tiles_to_entity = (45, 47)
+
def get_layer(data, name):
for layer in data["layers"]:
@@ -72,6 +75,7 @@ def main():
map_layer = get_layer(data, "Map")
out = list(map(lambda x: (x - tileset["firstgid"]) & 0xFF, map_layer["data"]))
+ door_cnt = sum(map(lambda x: 1 if x in tiles_to_entity else 0, out))
gold_layer = get_layer(data, "Gold")
@@ -90,8 +94,9 @@ def main():
# should help the drawing order in the game
objs_sorted = sorted(entity_layer["objects"], key=lambda o: o["y"])
- if args.max_ents and len(objs_sorted) > args.max_ents:
- parser.error("Too many entities (limit: %s)" % args.max_ents)
+ total_ents = len(objs_sorted) + door_cnt
+ if args.max_ents and total_ents > args.max_ents:
+ parser.error("Too many entities %d (limit: %s)" % (total_ents, args.max_ents))
for ent in objs_sorted:
try: