Some code cleanup
This commit is contained in:
parent
8d642f694d
commit
be1e8a658f
4 changed files with 8 additions and 5 deletions
|
|
@ -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)
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
|
|
|
|||
Binary file not shown.
|
Before Width: | Height: | Size: 982 B After Width: | Height: | Size: 1.1 KiB |
|
|
@ -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
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue