extends Panel var enemy_pre = preload("res://Objects/Entity.tscn") var item_pre = preload("res://Objects/item.tscn") var enemy = null var item = null var e_speed = 50 var e_life = 2 var spawn_rate = 3 var spawn_speed = 3.5 var rng = RandomNumberGenerator.new() var Time = 0 # Called when the node enters the scene tree for the first time. func _ready(): rng.randomize() if rng.randi_range(0, spawn_rate) == 0: enemy = enemy_pre.instance() add_child(enemy) var Progressbars = get_tree().get_nodes_in_group("XP") for Progressbar in Progressbars: Progressbar.connect("full_bar", self, "set_spawn_values") pass func _process(delta): Time += delta if Time > spawn_speed: rng.randomize() if rng.randi_range(0, spawn_rate) == 0: if rng.randi_range(0, 10) != 0: enemy = enemy_pre.instance() enemy.speed = e_speed enemy.life = e_life add_child(enemy) else: item = item_pre.instance() item.speed = e_speed add_child(item) Time = 0 func set_spawn_values(value): e_speed += value e_life *= 2 if (spawn_rate > 1): spawn_rate -= 1 elif spawn_speed > 1.5: spawn_speed -= 0.1 pass