import res.Object;

using Math;

class Rocket {
	public var obj:Object;

	var origY:Float;

	var totalTime:Float;
	var time:Float = 1;

	public var damage:Int = 100;
	public var cost:Int = 10;

	public function new(obj:Object, atX:Float, atY:Float, travelTime:Float = 1, damage:Int = 100, cost:Int = 10) {
		this.obj = obj;
		obj.x = atX - obj.width / 2;
		obj.y = origY = atY;

		totalTime = time = travelTime;

		this.damage = damage;
		this.cost = cost;
	}

	public function update(dt:Float) {
		if (time <= 0) {
			obj.toRemove = true;
		} else {
			final t = (time / totalTime);
			obj.y = origY * (1 - (1 - t).pow(3));
			time -= dt;
		}
	}
}
