summaryrefslogtreecommitdiff
path: root/src/prefab/hall.moon
diff options
context:
space:
mode:
authorAlexander M Pickering <alex@cogarr.net>2025-01-21 16:02:51 -0600
committerAlexander M Pickering <alex@cogarr.net>2025-01-21 16:02:51 -0600
commit0370d64b3bd7914be55358817e52bbc8a529a7d3 (patch)
treea717bb9582f8a4c8dc7caf0d455e25113c7b8704 /src/prefab/hall.moon
parentda9dd31f504d30f33922cdf362a7c01673a6b927 (diff)
downloadggj25-0370d64b3bd7914be55358817e52bbc8a529a7d3.tar.gz
ggj25-0370d64b3bd7914be55358817e52bbc8a529a7d3.tar.bz2
ggj25-0370d64b3bd7914be55358817e52bbc8a529a7d3.zip
work
Diffstat (limited to 'src/prefab/hall.moon')
-rw-r--r--src/prefab/hall.moon21
1 files changed, 21 insertions, 0 deletions
diff --git a/src/prefab/hall.moon b/src/prefab/hall.moon
new file mode 100644
index 0000000..59dbea0
--- /dev/null
+++ b/src/prefab/hall.moon
@@ -0,0 +1,21 @@
+util = require("util")
+
+-- Halls run from one point to another, the start and end points are in the
+-- middle of the hallway.
+-- "floor_gen" can be a string (the sprites texture to use)a
+-- or a function (passed the "Hall" object to generate the texture for that segment.
+class Hall
+ new: (tbl) =>
+ util.typecheck(tbl,
+ "startx", "number",
+ "starty", "number",
+ "endx", "number",
+ "endy", "number",
+ "width", "number"
+ )
+ assert(tbl.floor_gen, "Hall requires a 'floor_gen' attribute")
+ if type(tbl.floor_gen) == "function"
+ @floor_gen = tbl.floor_gen
+ elseif type(tbl.floor_gen) == "string"
+ @floor_gen = () =>
+ tbl.floor_gen