import res.Object;
import res.Sprite;

class MegaTank extends Object {
	public static final maxHealth:Int = 15000;

	public var health:Int = maxHealth;

	var phase:Float = 0;

	var shotDelay:Float = 5;

	public dynamic function shot() {};

	public function new(sprite:Sprite) {
		super(sprite);
	}

	override function update(dt:Float) {
		super.update(dt);

		if (health > 0) {
			x = -50 + ((1 + Math.sin(phase)) / 2) * (150);

			phase += (Math.PI / 8) * dt;

			if (shotDelay <= 0) {
				shot();
				shotDelay = 5 + Math.random() * 30;
			} else
				shotDelay -= dt;
		}
	}
}
