package de.frajul.endlessroll.main.game;

/**
 * Created by Julian on 22.05.2017.
 */

public class Camera {

    private final float MOVE_SPEED_UP = 0.7f;
    private final float MOVE_SPEED_DOWN = 0.7f;
    private final float MAX_Y = 0.5f;
    private final float MIN_Y = 0;
    private float x, y;

    public void update(float playerY, Timer timer){
        float frameTime = timer.getFrameTimeSeconds() / 1000f;
        float maxY = Math.min(playerY - 1 + 0.6f, MAX_Y);
        if(playerY >= 0.5f){
            y += MOVE_SPEED_UP * frameTime;
            if(y > maxY)
                y = maxY;
        } else if(y > MIN_Y){
            y -= MOVE_SPEED_DOWN * frameTime;
            if(y < MIN_Y)
                y = MIN_Y;
        }
    }

    public void moveX(float move){
        x += move;
    }

    public void reset(){
        x = 0;
        y = 0;
    }

    public float getX() {
        return x;
    }

    public float getY() {
        return y;
    }
}
