diff options
Diffstat (limited to 'scripts/path_generator.gd')
-rw-r--r-- | scripts/path_generator.gd | 15 |
1 files changed, 5 insertions, 10 deletions
diff --git a/scripts/path_generator.gd b/scripts/path_generator.gd index 87fedc3..cf48175 100644 --- a/scripts/path_generator.gd +++ b/scripts/path_generator.gd @@ -2,29 +2,24 @@ extends Object class_name PathGenerator -var _grid_width : int -var _grid_height : int - -func _init(width:int, height:int): - _grid_width = width - _grid_height = height +var map_config : MapGeneratorResource = preload("res://resources/map_generator_resource.tres") func generate_path() -> Array[Vector2i]: var path : Array[Vector2i] var x : int = 0 - var y : int = randi_range(1, _grid_height-2) + var y : int = randi_range(1, map_config.grid_height - 3) - while x < _grid_width: + while x < map_config.grid_width: if not path.has(Vector2i(x,y)): path.append(Vector2i(x, y)) var choice : int = randi_range(0,2) # every even tile goes right to leave room for towers - if choice == 0 || x % 2 == 0 || x == _grid_width - 1: + if choice == 0 || x % 2 == 0 || x == map_config.grid_width - 1: x += 1 - elif choice == 1 && y < _grid_height - 2 && !path.has(Vector2i(x, y + 1)): + elif choice == 1 && y < map_config.grid_height - 3 && !path.has(Vector2i(x, y + 1)): y += 1 elif choice == 2 && y > 1 && !path.has(Vector2i(x, y - 1)): y -= 1 |