Parameterize maximum room size; make minimum_room_size the actual floor size, not counting walls
This commit is contained in:
parent
e1044f3a73
commit
50d6550e17
1 changed files with 7 additions and 3 deletions
|
@ -45,11 +45,13 @@ class RoomsAndCorridorsGenerator(MapGenerator):
|
||||||
'''Generate a rooms-and-corridors style map with BSP.'''
|
'''Generate a rooms-and-corridors style map with BSP.'''
|
||||||
|
|
||||||
class Configuration:
|
class Configuration:
|
||||||
def __init__(self, min_room_size: Size):
|
def __init__(self, min_room_size: Size, max_room_size: Size):
|
||||||
self.minimum_room_size = min_room_size
|
self.minimum_room_size = min_room_size
|
||||||
|
self.maximum_room_size = max_room_size
|
||||||
|
|
||||||
DefaultConfiguration = Configuration(
|
DefaultConfiguration = Configuration(
|
||||||
min_room_size=Size(8, 8)
|
min_room_size=Size(5, 5),
|
||||||
|
max_room_size=Size(15, 15),
|
||||||
)
|
)
|
||||||
|
|
||||||
def __init__(self, *, size: Size, config: Optional[Configuration] = None):
|
def __init__(self, *, size: Size, config: Optional[Configuration] = None):
|
||||||
|
@ -66,12 +68,14 @@ class RoomsAndCorridorsGenerator(MapGenerator):
|
||||||
return self.tiles
|
return self.tiles
|
||||||
|
|
||||||
minimum_room_size = self.configuration.minimum_room_size
|
minimum_room_size = self.configuration.minimum_room_size
|
||||||
|
maximum_room_size = self.configuration.maximum_room_size
|
||||||
|
|
||||||
# Recursively divide the map into squares of various sizes to place rooms in.
|
# Recursively divide the map into squares of various sizes to place rooms in.
|
||||||
bsp = tcod.bsp.BSP(x=0, y=0, width=self.size.width, height=self.size.height)
|
bsp = tcod.bsp.BSP(x=0, y=0, width=self.size.width, height=self.size.height)
|
||||||
bsp.split_recursive(
|
bsp.split_recursive(
|
||||||
depth=4,
|
depth=4,
|
||||||
min_width=minimum_room_size.width, min_height=minimum_room_size.height,
|
# Add 2 to the minimum width and height to account for walls
|
||||||
|
min_width=minimum_room_size.width + 2, min_height=minimum_room_size.height + 2,
|
||||||
max_horizontal_ratio=1.5, max_vertical_ratio=1.5)
|
max_horizontal_ratio=1.5, max_vertical_ratio=1.5)
|
||||||
|
|
||||||
tiles = np.full(tuple(self.size), fill_value=Wall, order='F')
|
tiles = np.full(tuple(self.size), fill_value=Wall, order='F')
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue