package com.jan.game;

import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.utils.viewport.ScreenViewport;
import com.badlogic.gdx.graphics.OrthographicCamera;

public class Display {
    private static boolean isInitialized = false;

    private static ScreenViewport viewPort;
    private static OrthographicCamera mainCamera;

    public static int DEFAULT_RESOLUTION_WIDTH = 960;
    public static int DEFAULT_RESOLUTION_HEIGHT = 640;

    private static float tileSize = 0;

    public static void initialize(){
        if(isInitialized == false){
            Gdx.graphics.setResizable(false);
            viewPort = new ScreenViewport();
            viewPort.setUnitsPerPixel(0.03125f);
            setResolution(DEFAULT_RESOLUTION_WIDTH, DEFAULT_RESOLUTION_HEIGHT);
            isInitialized = true;
        }
    }

    public static void setResolution(int width, int height){
        Gdx.graphics.setWindowedMode(width, height);
        viewPort.update(width, height);
        useCamera((OrthographicCamera)viewPort.getCamera());
    }
    public static void useCamera(OrthographicCamera camera){
        viewPort.setCamera(camera);
        mainCamera = (OrthographicCamera) viewPort.getCamera();
    }

    public static void update(){
        mainCamera.update();
    }

    public static OrthographicCamera getCamera(){ return mainCamera; }
    
    public static void setScale(float scale){ tileSize = scale; }
    public static float getScale(){ return tileSize; }
}
