package de.samdev.colorrunner.screens.menu.impl;

import com.badlogic.gdx.Game;
import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.Screen;
import com.badlogic.gdx.graphics.GL20;
import com.badlogic.gdx.graphics.OrthographicCamera;
import com.badlogic.gdx.graphics.Texture;
import com.badlogic.gdx.graphics.g2d.SpriteBatch;
import com.badlogic.gdx.math.MathUtils;

import de.samdev.colorrunner.CRGame;


public class SplashScreen implements Screen {

	private float loadTime = 0;
	
	private int random = MathUtils.random(5);
	private Texture logo = new Texture("images/blackforestbytes_appstart.png");
    
    private OrthographicCamera cam = new OrthographicCamera();
	private SpriteBatch sB;

	
	@Override
	public void render(float delta) {
		Gdx.gl.glClearColor(1, 1, 1, 1);				//Weiß
		Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT);

    	sB.begin();
		sB.draw(logo, -9,-8, 18, 16);
		sB.end();

		loadTime += delta;
		if (loadTime > 0.9)
			CRGame.Inst().setScreen(new LevelSelectMenu());
	}

	@Override
	public void resize(int width, int height) {
		// NOP
		
	}

	@Override
	public void show() {
	
		sB = new SpriteBatch();

		this.cam = new OrthographicCamera(20,40);
		this.cam.position.set(20 / 2, 40 / 2, 0);
		sB.setProjectionMatrix(cam.combined);
		cam.update();
		
	}

	@Override
	public void hide() {
		dispose();
		
	}

	@Override
	public void pause() {
		// NOP
		
	}

	@Override
	public void resume() {
		// NOP
		
	}

	@Override
	public void dispose() {
        logo.dispose();
		
	}

}
