From 0127a8ec6c66a9abaeb97f0b02b70d5d91a835cc Mon Sep 17 00:00:00 2001 From: Lucas Fryzek Date: Thu, 26 Sep 2024 15:59:53 +0100 Subject: bsp_level_generator: Add special door tile Having a specific door tile will prevent overlapping doors from generating as the check for a floor next to the door will fail. --- scripts/bsp_level_generator.gd | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) (limited to 'scripts/bsp_level_generator.gd') diff --git a/scripts/bsp_level_generator.gd b/scripts/bsp_level_generator.gd index 4a1ca9b..664b7a5 100644 --- a/scripts/bsp_level_generator.gd +++ b/scripts/bsp_level_generator.gd @@ -111,8 +111,8 @@ func generate_grid(map: BSPNode, grid: Array[Tile.Tile]) -> void: have_door = true # Place grid for mesh - grid[door_pos.y * grid_width + door_pos.x] = Tile.Tile.FLOOR - grid[door_pos2.y * grid_width + door_pos2.x] = Tile.Tile.FLOOR + grid[door_pos.y * grid_width + door_pos.x] = Tile.Tile.DOOR + grid[door_pos2.y * grid_width + door_pos2.x] = Tile.Tile.DOOR #door_pos[map.axis] -= 1 #grid[door_pos.y * grid_width + door_pos.x] = Tile.Tile.FLOOR @@ -146,14 +146,13 @@ func generate_geo(grid: Array[Tile.Tile], array: Array) -> void: for x in range(grid_width): var tile = grid[y * grid_width + x] - if tile == Tile.Tile.FLOOR: + if tile == Tile.Tile.FLOOR or tile == Tile.Tile.DOOR: generate_plane(array, Vector3(x, 0, y), [Vector3(1, 0, 0), Vector3(0, 0, 1)], Vector3.UP) elif tile == Tile.Tile.WALL: - generate_plane(array, Vector3(x, 2, y), [Vector3(0, 0, 1), Vector3(0, -2, 0)], Vector3.RIGHT) + generate_plane(array, Vector3(x, 2, y), [Vector3(0, 0, 1), Vector3(0, -2, 0)], Vector3.LEFT) generate_plane(array, Vector3(x, 2, y+1), [Vector3(1, 0, 0), Vector3(0, -2, 0)], Vector3.BACK) - generate_plane(array, Vector3(x+1, 2, y+1), [Vector3(0, 0, -1), Vector3(0, -2, 0)], Vector3.LEFT) + generate_plane(array, Vector3(x+1, 2, y+1), [Vector3(0, 0, -1), Vector3(0, -2, 0)], Vector3.RIGHT) generate_plane(array, Vector3(x+1, 2, y), [Vector3(-1, 0, 0), Vector3(0, -2, 0)], Vector3.FORWARD) - pass func _ready() -> void: var starting_axis = randi_range(0, 1) -- cgit