summaryrefslogtreecommitdiff
path: root/src/prefab/hall.moon
diff options
context:
space:
mode:
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