diff --git a/squirrelbattle/mapgeneration/broguelike.py b/squirrelbattle/mapgeneration/broguelike.py index db81065..f60d423 100644 --- a/squirrelbattle/mapgeneration/broguelike.py +++ b/squirrelbattle/mapgeneration/broguelike.py @@ -110,6 +110,12 @@ class Generator: self.place_room(level, height//2, width//2, 0, 0, starting_room) self.params["corridor"] = mem + # find a starting position + sy, sx = randint(0, height-1), randint(0, width-1) + while level[sy][sx] != Tile.FLOOR: + sy, sx = randint(0, height-1), randint(0, width-1) + + # now we loop until we've tried enough, or we've added enough rooms tries, rooms_built = 0, 0 while tries < self.params["tries"] and rooms_built < self.params["max_rooms"]: @@ -124,4 +130,4 @@ class Generator: # post-processing self.place_walls(level) - return level + return Map(width, height, level, sy, sx)