package ir.codeandroid.game;

/**
 * Created by ARM on 5/27/2018.
 */


import android.graphics.Rect;

public class Golole {
    private int x, y, speedX;
    private boolean visible;
    private Rect r;


    public Golole(int startX, int startY) {
        x = startX;
        y = startY;
        speedX = 7;
        visible = true;
        r = new Rect(0, 0, 0, 0);
    }

    public void update() {
        x += speedX;
        r.set(x, y, x+10, y+5);
        if (x > 800) {
            visible = false;
            r = null;
        }
        if (x < 801) {
            barresiBarkhord();
        }
    }

    private void barresiBarkhord() {
        if (Rect.intersects(r, GameScreen.hb.r)) {
            visible = false;
            if (GameScreen.hb.salamati > 0) {
                GameScreen.hb.salamati -= 1;
            }
            if (GameScreen.hb.salamati == 0) {
                GameScreen.hb.setCenterX(-100);
                GameScreen.emtiaz += 5;


            }
        }
        if (Rect.intersects(r, GameScreen.hb2.r)) {
            visible = false;
            if (GameScreen.hb2.salamati > 0) {
                GameScreen.hb2.salamati -= 1;
            }
            if (GameScreen.hb2.salamati == 0) {
                GameScreen.hb2.setCenterX(-100);
                GameScreen.emtiaz += 5;
            }
        }
    }

    public int getX() {
        return x;
    }

    public int getY() {
        return y;
    }

    public int getSpeedX() {
        return speedX;
    }

    public boolean isVisible() {
        return visible;
    }

    public void setX(int x) {
        this.x = x;
    }

    public void setY(int y) {
        this.y = y;
    }

    public void setSpeedX(int speedX) {
        this.speedX = speedX;
    }

    public void setVisible(boolean visible) {
        this.visible = visible;
    }

}
