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. --- prefabs/test_arena.tscn | 2 +- scripts/bsp_level_generator.gd | 11 +++++------ scripts/tile.gd | 2 +- 3 files changed, 7 insertions(+), 8 deletions(-) diff --git a/prefabs/test_arena.tscn b/prefabs/test_arena.tscn index b56da43..cccb951 100644 --- a/prefabs/test_arena.tscn +++ b/prefabs/test_arena.tscn @@ -78,7 +78,7 @@ script = ExtResource("1_dbsm0") environment = SubResource("Environment_2poci") [node name="OmniLight3D" type="DirectionalLight3D" parent="."] -transform = Transform3D(1, 0, 0, 0, 0.707107, 0.707107, 0, -0.707107, 0.707107, 0, 0, -0.0795405) +transform = Transform3D(0.838671, -0.296632, 0.456773, 0, 0.838671, 0.544639, -0.544639, -0.456773, 0.703368, 0, 0, -0.0795405) [node name="Player" parent="." node_paths=PackedStringArray("HEAD", "HEADBOB_ANIMATION") instance=ExtResource("1_vc6b5")] transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 3, 0, 3) 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) diff --git a/scripts/tile.gd b/scripts/tile.gd index 6243b9c..87bc2a3 100644 --- a/scripts/tile.gd +++ b/scripts/tile.gd @@ -1,3 +1,3 @@ extends Node -enum Tile {FLOOR, WALL} +enum Tile {FLOOR, WALL, DOOR} -- cgit