diff options
author | bd <bdunahu@operationnull.com> | 2025-05-22 21:10:02 -0400 |
---|---|---|
committer | bd <bdunahu@operationnull.com> | 2025-05-22 21:10:02 -0400 |
commit | 5af13cd2c4e87c6e273d4c8d84c06cd6a320b427 (patch) | |
tree | 0e55a3c0c823481106c8c553fee9510eaa734305 /scripts/path_generator.gd | |
parent | a95e2ead7e3ade3c13e4e9f6e68c24df4430097a (diff) |
Make resource file for common map variables
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 |