Now About Social Code
summaryrefslogtreecommitdiff
path: root/scripts/dungeon_manager.gd
diff options
context:
space:
mode:
Diffstat (limited to 'scripts/dungeon_manager.gd')
-rw-r--r--scripts/dungeon_manager.gd10
1 files changed, 9 insertions, 1 deletions
diff --git a/scripts/dungeon_manager.gd b/scripts/dungeon_manager.gd
index 12b80fa..39b6131 100644
--- a/scripts/dungeon_manager.gd
+++ b/scripts/dungeon_manager.gd
@@ -45,8 +45,16 @@ func create_exit() -> void:
exit.connect("body_entered", _on_player_exit)
while not found_pos:
var pos = Vector2i(randi_range(0, grid_width-1), randi_range(0, grid_height-1))
+ var left = pos + Vector2i.LEFT
+ var right = pos + Vector2i.RIGHT
+ var up = pos + Vector2i.UP
+ var down = pos + Vector2i.DOWN
- if grid[pos.y * grid_width + pos.x] == Tile.Tile.FLOOR:
+ if grid[pos.y * grid_width + pos.x] == Tile.Tile.FLOOR \
+ and grid[left.y * grid_width + left.x] == Tile.Tile.FLOOR \
+ and grid[right.y * grid_width + right.x] == Tile.Tile.FLOOR \
+ and grid[up.y * grid_width + up.x] == Tile.Tile.FLOOR \
+ and grid[down.y * grid_width + down.x] == Tile.Tile.FLOOR:
exit.position = Vector3(pos.x, 0, pos.y) + Vector3(0.5, 0, 0.5)
found_pos = true