extends Node2D var spawn var location = preload("res://Scenes/Locations/yard.tscn") var horse_scene = preload("res://Scenes/horse.tscn") var horse = preload("res://Scripts/horse.gd") var horse_instance var mouse_position = Vector2.ZERO var ccVanilla = preload("res://Scenes/Cupcakes/cupcake.tscn") var ccvan = ccVanilla.instantiate() var ccChocolate var ccchoc var randX var randY var ccSpawnRate = 10 var ccCount = 0 var ccMaxOnScreen = 250 func _ready(): horse_instance = horse_scene.instantiate() spawn = location.instantiate() $Location.add_child(spawn) add_child(horse_instance) func _process(delta): mouse_position = get_global_mouse_position() horse_instance.position = mouse_position func spawnCupcakes(): randomize() if ccCount <= ccMaxOnScreen: for i in range(ccSpawnRate): randX = randi_range(10, 1910) randY = randi_range(10, 1070) ccvan.position = Vector2(randX, randY) $PlayArea.add_child(ccvan.duplicate()) ccCount = ccCount + 1 func collectCupcakes(): pass func _on_timeout(): var timer = get_node("Cupcake Spawn Timer") spawnCupcakes() timer.start func _on_play_area_area_exited(area): pass func _on_play_area_body_exited(body): if body.is_in_group("Cupcake"): horse.ccVanNum += 1 print(horse.ccVanNum) body.queue_free() func _on_play_area_area_shape_exited(area_rid, area, area_shape_index, local_shape_index): pass # Replace with function body.