package Game;

import java.awt.Graphics;
import java.util.ArrayList;
import javaPlay.GameEngine;
import javaPlay.GameStateController;
import javaPlay.Sprite;

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/**
 *
 * @author Jose Ricardo
 */
public class MainMenuGameState implements GameStateController {

    // Sprite com a tela de fundo
    Sprite background = null;

    // Array de menus
    ArrayList<MenuItem> menus = new ArrayList<MenuItem>();

    public void load() {
        // Carregar tela de fundo
        background = new Sprite("data/menu_back.png", 1, Globals.VIEWPORT_WIDTH,
                Globals.VIEWPORT_HEIGHT);

        // Carregar menu iniciar
        MenuItem mnuIniciar = new MenuItem("data/menu_iniciar.png",
                Globals.MENU_START_WIDTH,
                Globals.MENU_START_HEIGHT, Globals.MENU_START_ID);
        mnuIniciar.x = (Globals.VIEWPORT_WIDTH / 2) - (Globals.MENU_START_WIDTH / 2);
        mnuIniciar.y = 200;
        menus.add(mnuIniciar);        
    }

    public void unload() {
        background = null;
        
    }

    public void start() {
        
    }

    public void step(long timeElapsed) {
        for (int i = 0; i < menus.size(); i++){
            if (menus.get(i).isSelected())
                switch(menus.get(i).getId()){
                    // Menu iniciar selecionado
                    case Globals.MENU_START_ID:
                        GameEngine.getInstance().setNextGameStateController(
                                Globals.SCREEEN_PLAYING);
                        break;
                }
        }
    }

    public void draw(Graphics g) {
        background.draw(g, 0, 0);

        for (int i = 0; i < menus.size(); i++)
            menus.get(i).draw(g);
    }

    public void stop() {
        
    }

}
