Walls now generate around the floor
This commit is contained in:
		@@ -16,6 +16,7 @@ DEFAULT_PARAMS = {
 | 
			
		||||
    "width": 100,
 | 
			
		||||
    "height": 100,
 | 
			
		||||
    "fill": .4,
 | 
			
		||||
    "no_lone_walls": False,
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@@ -101,4 +102,15 @@ class Generator:
 | 
			
		||||
        while grid[start_y][start_x] != Tile.FLOOR:
 | 
			
		||||
            start_x, start_y = randint(0, width - 1), randint(0, height - 1)
 | 
			
		||||
 | 
			
		||||
        return Map(width, height, grid, start_y, start_x)
 | 
			
		||||
        result = Map(width, height, grid, start_y, start_x)
 | 
			
		||||
 | 
			
		||||
        # post-processing: add walls
 | 
			
		||||
        for x in range(width):
 | 
			
		||||
            for y in range(height):
 | 
			
		||||
                c = sum([1 if grid[j][i] == Tile.FLOOR else 0 for j, i in result.neighbours_large(y, x)])
 | 
			
		||||
                if c == 4 and self.params["no_lone_walls"]:
 | 
			
		||||
                    result.tiles[y][x] = Tile.FLOOR
 | 
			
		||||
                elif c > 0:
 | 
			
		||||
                    result.tiles[y][x] = Tile.WALL
 | 
			
		||||
 | 
			
		||||
        return result
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user