package com.mygdx.game;

import com.badlogic.gdx.ApplicationAdapter;
import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.audio.Music;
import com.badlogic.gdx.graphics.Color;
import com.badlogic.gdx.graphics.GL20;
import com.badlogic.gdx.graphics.g2d.BitmapFont;
import com.badlogic.gdx.graphics.g2d.SpriteBatch;

import menus.Fin;
import menus.Menu;
import menus.MenuInicio;
import menus.MenuOpcions;
import menus.MenuSeleccion;
import menus.MenuSeleccion2p;
import utilidades.Gifs;

public class MyGdxGame extends ApplicationAdapter {
	SpriteBatch batch;
	BitmapFont font;
	int WIN_ALT;
	int WIN_ANCH;
	float contadorGif = 0;
	Gifs pinchos;
	int menuSeleccionado=0;
	int aux=menuSeleccionado;
	boolean fin=false;
	Color color;
	Music musica;
	@Override
	public void create () {
		this.musica=Gdx.audio.newMusic(Gdx.files.internal("musica.mp3"));
		musica.play();
		musica.setLooping(true);
		this.color=new Color();
		color.set(0.5f, 0, 0, 1);
		batch = new SpriteBatch();
		font = new BitmapFont(Gdx.files.internal("CentieSans.fnt"));
		WIN_ALT=900;
		WIN_ANCH=700;
		Gdx.graphics.setWindowedMode(WIN_ALT, WIN_ANCH);
		Menu.menus.add(new MenuInicio());
		Menu.menus.add(new MenuOpcions(color));
		Menu.menus.add(new MenuSeleccion());
		Menu.menus.add(new MenuSeleccion2p());
		Menu.menus.add(new Fin());
	}

	@Override
	public void render () {
		Gdx.gl.glClearColor(color.r, color.g, color.b, color.a);
		Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT);
		batch.begin();
		float delta = Gdx.graphics.getDeltaTime();
		this.menuSeleccionado=Menu.menus.get(this.menuSeleccionado).draw(batch, delta);
		batch.end();
	}
	
	@Override
	public void dispose () {
		musica.dispose();
		batch.dispose();
		font.dispose();
		Menu.menus.get(this.menuSeleccionado).dispose();
	}
}
