package com.ady.timerunner;

import com.badlogic.gdx.math.MathUtils;
import com.badlogic.gdx.math.Vector2;

/**
 * Created by ADY on 27.1.2018.
 */

public class Bubble {
    private float randoma;
    private float randomb;
    public float height;
    public float worldradius;
    public Vector2 center;
    public float angle;
    private float sizeacc = 0.02f;
    public float speed;
    Vector2 position = new Vector2(5, 5);
    public float size = MathUtils.random(0.2f, 0.7f);
    public boolean dead = false;


    public Bubble(float x, float y, float speed, Vector2 center, float angle, float worldradius, float height) {
        position.set(x, y);
        this.speed = speed;
        this.height = height;
        this.center = center;
        this.angle = angle;
        this.worldradius = worldradius;
        randoma = MathUtils.random(-10f, 10f);
        randomb = MathUtils.random(-10f, 10f);
    }


    public void act() {
        sizeacc += 0.003f;
        size += sizeacc;
        height -= speed;
        angle -= speed/12f;

        speed *=0.90f;
        if (size > 4f) {
            dead = true;
        }
        Vector2 smoke=new Vector2(5,5);
        smoke.setLength(50);
        smoke.setAngle(angle+90);
        position = center.cpy().add(MathUtils.cosDeg(angle) * (worldradius  + height +50)+25, MathUtils.sinDeg(angle) * (worldradius  + height +50)+25).add(smoke);

    }

    public Vector2 getPosition()
    {
        return position.cpy().add(randoma,randomb);

    }
}
