18 lines
592 B
GDScript
18 lines
592 B
GDScript
extends Node
|
|
|
|
@export var n_plants_to_generate: int
|
|
@export var space_between_plants: float
|
|
|
|
func _ready():
|
|
generate_plants();
|
|
|
|
func generate_plants():
|
|
for i in n_plants_to_generate:
|
|
var plant_position := Vector2(i * space_between_plants, 0)
|
|
var plant_data: PlantData = PlantData.new(plant_position)
|
|
plant_data.day = plant_data.get_growing_time()
|
|
plant_data.mutations.append(plant_data.archetype.available_mutations.pick_random())
|
|
var plant: Plant = Plant.new(plant_data)
|
|
add_child(plant)
|
|
plant.global_position = plant_position
|