extends Node

#The time, in seconds, it should take for the character to grow up
export var GrowUpTime = 2.0
export var IsBigTime = 5.0
export var GrowDownTime = 1.0

#How much bigger should the player become
export var GrowUpFactor = 5

#How much slower should the player become
export var SlowFactor = 1.0 / 6.0

func GiantRoutine(player, delta):
	var elapsed = delta
	var small_scale = player.transform.get_scale()
	var big_scale = player.transform.get_scale() * GrowUpFactor
	var sprite = player.get_node("Sprite")
	var coll = player.get_node("CollisionShape2D")
	var conf = player.get_node("ConfusionStars")
	
	while elapsed < GrowUpTime:
		player.SPEED_FACTORS.append(lerp(1, SlowFactor, elapsed / GrowUpTime))
		player.ACCELERATION_FACTORS.append(lerp(1, SlowFactor, elapsed / GrowUpTime))
		player.SCALE_FACTORS.append(lerp(1, GrowUpFactor, elapsed / GrowUpTime))		
		elapsed += yield()
		
	elapsed -= GrowUpTime;
	while elapsed < IsBigTime:
		player.SPEED_FACTORS.append(SlowFactor)
		player.ACCELERATION_FACTORS.append(SlowFactor)
		player.SCALE_FACTORS.append(GrowUpFactor)
		elapsed += yield()
	elapsed -= IsBigTime;
		
	while elapsed < GrowDownTime:
		player.SPEED_FACTORS.append(lerp(SlowFactor, 1, elapsed / GrowDownTime))
		player.ACCELERATION_FACTORS.append(lerp(SlowFactor, 1, elapsed / GrowDownTime))
		player.SCALE_FACTORS.append(lerp(GrowUpFactor, 1, elapsed / GrowDownTime))
		elapsed += yield()
	
func StartEffect(player):
	var rout = GiantRoutine(player, 0)
	return rout
	
