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 = 25 var ccCount = 0 var ccMaxOnScreen = 2000 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 + 25 func collectCupcakes(): pass func _on_timeout(): var timer = get_node("Cupcake Spawn Timer") spawnCupcakes() timer.start func _on_play_area_body_exited(body): pass