From a95e2ead7e3ade3c13e4e9f6e68c24df4430097a Mon Sep 17 00:00:00 2001 From: bd Date: Thu, 22 May 2025 20:24:01 -0400 Subject: Make WaveSpawner, Cursor, use generated paths --- scripts/path_generator.gd | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) (limited to 'scripts/path_generator.gd') diff --git a/scripts/path_generator.gd b/scripts/path_generator.gd index 0e9719a..87fedc3 100644 --- a/scripts/path_generator.gd +++ b/scripts/path_generator.gd @@ -5,29 +5,27 @@ class_name PathGenerator var _grid_width : int var _grid_height : int -var _path : Array[Vector2i] - func _init(width:int, height:int): _grid_width = width _grid_height = height -func generate_path(): - _path.clear() +func generate_path() -> Array[Vector2i]: + var path : Array[Vector2i] var x : int = 0 var y : int = randi_range(1, _grid_height-2) while x < _grid_width: - if not _path.has(Vector2i(x,y)): - _path.append(Vector2i(x, y)) + 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: x += 1 - elif choice == 1 && y < _grid_height - 2 && !_path.has(Vector2i(x, y + 1)): + elif choice == 1 && y < _grid_height - 2 && !path.has(Vector2i(x, y + 1)): y += 1 - elif choice == 2 && y > 1 && !_path.has(Vector2i(x, y - 1)): + elif choice == 2 && y > 1 && !path.has(Vector2i(x, y - 1)): y -= 1 - return _path + return path -- cgit v1.2.3