summaryrefslogtreecommitdiff
path: root/src/prefab/hall.moon
blob: 59dbea0515fbd3fffc0a9c4b17891f10157009fc (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
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