extends Node2D var texture_new_sprite : Texture var biom_n = preload("res://assets/Ground/n.png") var biom_n_w = preload("res://assets/Ground/n_w.png") var biom_w_n = preload("res://assets/Ground/w_n.png") var biom_w = preload("res://assets/Ground/w.png") var active_biom = "n" var passed func probability(prozent): return randf() > 1-(0.01*20) # 20% warscheinlichkeit um biom zu tauschen func handle_biom_change(): if active_biom == "n": if probability(20): active_biom = "n_w" elif active_biom == "n_w": active_biom = "w" elif active_biom == "w": active_biom = "w_n" elif active_biom == "w_n": active_biom = "n" set_biom_texture() func set_biom_texture(): #print("activebiom_s: " + active_biom) if active_biom == "w": texture_new_sprite = biom_w elif active_biom == "n": texture_new_sprite = biom_n elif active_biom == "w_n": texture_new_sprite = biom_w_n elif active_biom == "n_w": texture_new_sprite = biom_n_w func _spawn(last_x_position) -> void: var new_ground = preload("res://scenes/ground/ground.tscn").instantiate() new_ground.texture = texture_new_sprite new_ground.global_position.x = last_x_position+400 add_child(new_ground) new_ground.connect("screen_entered",_on_ground_sprite_screen_entered) func _on_ground_sprite_screen_entered() -> void: handle_biom_change() _spawn(get_child(0).position.x)