summaryrefslogtreecommitdiff
path: root/scripts/path_generator.gd
diff options
context:
space:
mode:
Diffstat (limited to 'scripts/path_generator.gd')
-rw-r--r--scripts/path_generator.gd16
1 files changed, 8 insertions, 8 deletions
diff --git a/scripts/path_generator.gd b/scripts/path_generator.gd
index 2b8a3a8..75322cc 100644
--- a/scripts/path_generator.gd
+++ b/scripts/path_generator.gd
@@ -20,7 +20,7 @@ func generate_path() -> Array[Vector2i]:
_path.clear()
var x : int = 0
- var y : int = randi_range(1, map_config.grid_height - 3)
+ var y : int = randi_range(1, map_config.grid_height - 2)
while x < map_config.grid_width:
if not _path.has(Vector2i(x,y)):
@@ -31,7 +31,7 @@ func generate_path() -> Array[Vector2i]:
# every even tile goes right to leave room for towers
if choice == 0 || x % 2 == 0 || x == map_config.grid_width - 1:
x += 1
- elif choice == 1 && y < map_config.grid_height - 3 && !_path.has(Vector2i(x, y + 1)):
+ elif choice == 1 && y < map_config.grid_height - 2 && !_path.has(Vector2i(x, y + 1)):
y += 1
elif choice == 2 && y > 1 && !_path.has(Vector2i(x, y - 1)):
y -= 1
@@ -40,7 +40,7 @@ func generate_path() -> Array[Vector2i]:
func draw_path():
for i in _path:
- var score : int = _get_tile_score(_path, i)
+ var score : int = _get_tile_score(i)
var atlas_coords : Vector2i = map_config.atlas_coords["PATH_EMPTY"]
var rot : TileTransform = TileTransform.ROTATE_0
@@ -68,14 +68,14 @@ func draw_path():
func _display_tile(coords : Vector2i, rot : TileTransform, pos : Vector2i):
_tile_map.set_cell(pos, 0, coords, rot)
-func _get_tile_score(path : Array[Vector2i], tile : Vector2i) -> int:
+func _get_tile_score(tile : Vector2i) -> int:
var score : int = 0
var x : int = tile.x
var y : int = tile.y
- score += 1 if path.has(Vector2i(x, y - 1)) else 0
- score += 2 if path.has(Vector2i(x + 1, y)) else 0
- score += 4 if path.has(Vector2i(x, y + 1)) else 0
- score += 8 if path.has(Vector2i(x - 1, y)) else 0
+ score += 1 if _path.has(Vector2i(x, y - 1)) else 0
+ score += 2 if _path.has(Vector2i(x + 1, y)) else 0
+ score += 4 if _path.has(Vector2i(x, y + 1)) else 0
+ score += 8 if _path.has(Vector2i(x - 1, y)) else 0
return score