diff --git a/vines_petals/bud.gd b/vines_petals/bud.gd index 3886b59..1e4302e 100644 --- a/vines_petals/bud.gd +++ b/vines_petals/bud.gd @@ -1,5 +1,6 @@ class_name Bud extends VineNode signal opened +var img_path func _on_opened(): $AnimatedSprite2D.play("open") @@ -19,5 +20,4 @@ func grow_to_next_bud(dir): var pos1 = grid.get_world_position(location, offset) var pos2 = grid.get_world_position(location + dir, target_offset) var num_seg = floor((pos1-pos2).length() / 96) - var path = "res://vines_petals/vine_active_green.png" - await vine.grow_vine_sequence(location, offset, location + dir, target_offset, num_seg, path, true) + await vine.grow_vine_sequence(location, offset, location + dir, target_offset, num_seg, true) diff --git a/vines_petals/vine.gd b/vines_petals/vine.gd index 7328597..7aa7046 100644 --- a/vines_petals/vine.gd +++ b/vines_petals/vine.gd @@ -3,8 +3,9 @@ var petal_location : Vector2 @export var vine_locations : Array[Vector2] @export var bud_resource : PackedScene @onready var grid : Grid = get_tree().get_root().get_node("main/Earth/Grid") +var img_path = "res://vines_petals/vine_active_green.png" -func draw_vine(pos1 : Vector2, pos2 : Vector2, img_path): +func draw_vine(pos1 : Vector2, pos2 : Vector2): var sprite = Sprite2D.new() get_tree().get_root().get_node("main").add_child(sprite) sprite.texture = ResourceLoader.load(img_path) @@ -12,8 +13,9 @@ func draw_vine(pos1 : Vector2, pos2 : Vector2, img_path): sprite.rotation = (pos1 - pos2).angle() + PI/2 sprite.scale *= (pos1 - pos2).length() * 1 / sprite.texture.get_width() sprite.scale.x = 3 + sprite.z_index = -1 -func grow_vine_sequence(location1 : Vector2, offset1 : Vector2, location2: Vector2, offset2 : Vector2, num_segments: int, img_path, grow_bud = false): +func grow_vine_sequence(location1 : Vector2, offset1 : Vector2, location2: Vector2, offset2 : Vector2, num_segments: int, grow_bud = false): var pos1 = grid.get_world_position(location1, offset1) var pos2 = grid.get_world_position(location2, offset2) var positions = [] @@ -28,7 +30,7 @@ func grow_vine_sequence(location1 : Vector2, offset1 : Vector2, location2: Vecto positions.append(center + offset) positions.append(pos2) for i in range(num_segments): - draw_vine(positions[i], positions[i+1], img_path) + draw_vine(positions[i], positions[i+1]) await get_tree().create_timer(0.2).timeout if grow_bud and location2.y > 0: spawn_bud(location2, offset2) diff --git a/vines_petals/vine_inactive.png b/vines_petals/vine_inactive.png index bc9de88..ac1712d 100644 Binary files a/vines_petals/vine_inactive.png and b/vines_petals/vine_inactive.png differ diff --git a/world/building_generator.gd b/world/building_generator.gd index 358191e..d006a55 100644 --- a/world/building_generator.gd +++ b/world/building_generator.gd @@ -25,6 +25,7 @@ func _ready(): if initial_spawn_protection and 43 <= collumn and collumn <= 49: continue var building = randomize_building() + building.z_index = -2 if grid.add_building_to_collumn(building, collumn): break