package com.hexabeast.lasermonster;

import com.badlogic.gdx.Game;
import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.audio.Sound;
import com.badlogic.gdx.graphics.Texture;
import com.badlogic.gdx.graphics.Texture.TextureFilter;
import com.badlogic.gdx.graphics.g2d.BitmapFont;
import com.badlogic.gdx.graphics.g2d.TextureRegion;

public class Main extends Game 
{
	GameScreen gameScreen;
	boolean began = false;
	
	public static int width = 1920;
	public static int height = 1080;
	
	public static Texture texBackground;
	public static Texture texRetry;
	public static Texture texForeground;
	public static Texture texCrame;
	public static Texture texEye;
	public static Texture texLaser;
	public static Texture texFire;
	public static Texture texStart;
	public static TextureRegion texFiree;
	public static Texture texEnnemy;
	public static TextureRegion[] texEnnemies;
	
	public static Sound laserSound;
	public static Sound hitSound;
	public static Sound stepSound;
	
	public static BitmapFont font;
	
	public static float delta;
	
	@Override
	public void create () 
	{
		laserSound = Gdx.audio.newSound(Gdx.files.internal("laser.wav"));
		hitSound = Gdx.audio.newSound(Gdx.files.internal("hit.wav"));
		stepSound = Gdx.audio.newSound(Gdx.files.internal("pas.wav"));
		
		font = new BitmapFont(Gdx.files.internal("font.fnt"),
                Gdx.files.internal("font.png"), false);
		font.getRegion().getTexture().setFilter(TextureFilter.Linear, TextureFilter.Linear);
		
		Inputs.instance = new Inputs();
		Gdx.input.setInputProcessor(Inputs.instance);
		
		texRetry = new Texture("retry.png");
		texRetry.setFilter(TextureFilter.Linear, TextureFilter.Linear);
		
		texStart = new Texture("start.png");
		texStart.setFilter(TextureFilter.Linear, TextureFilter.Linear);
		
		texEye = new Texture("eye.png");
		texEye.setFilter(TextureFilter.Linear, TextureFilter.Linear);
		texCrame = new Texture("crame.png");
		texCrame.setFilter(TextureFilter.Linear, TextureFilter.Linear);
		texForeground = new Texture("foreground.png");
		texForeground.setFilter(TextureFilter.Linear, TextureFilter.Linear);
		texBackground = new Texture("background.png");
		texBackground.setFilter(TextureFilter.Linear, TextureFilter.Linear);
		texLaser = new Texture("laser.png");
		texLaser.setFilter(TextureFilter.Linear, TextureFilter.Linear);
		
		texFire = new Texture("fire.png");
		texFire.setFilter(TextureFilter.Linear, TextureFilter.Linear);
		texFiree = new TextureRegion(texFire);
		
		texEnnemy = new Texture("ennemy.png");
		texEnnemy.setFilter(TextureFilter.Linear, TextureFilter.Linear);
		
		texEnnemies = new TextureRegion(texEnnemy).split(130, texEnnemy.getHeight())[0];
		
		gameScreen = new GameScreen();
	}

	@Override
	public void render () 
	{
		
		
		
		super.render();
		
		
		delta = Gdx.graphics.getDeltaTime();
		if(delta<=0)delta = 0.0001f;
		if(delta>0.1f)delta = 0.1f;
		
		Inputs.instance.update();
		
		if(!began)
		{
			began = true;
			setScreen(gameScreen);
		}
	}
}
