extends Area2D

export var power_x = 0
export var power_y = 1500

var player = null

# warning-ignore:unused_argument
func _physics_process(delta):
	var collect = false
	for obj in get_overlapping_bodies():
		if (obj.is_in_group("Player")):
			player = obj
			collect = true
	if collect: collect()


func collect():
	
	player.position.y = player.position.y - 35
	#if power_x != 0:
	player.velocity.x = -power_x
	#if power_y != 0:
	player.velocity.y = -power_y
	
	Audio.play_sfx("spring")
	$AnimatedSprite.play("Spring")


func _on_AnimatedSprite_animation_finished():
	if $AnimatedSprite.animation == "Spring":
		$AnimatedSprite.play("Normal")
	pass # Replace with function body.
