package sk.perri.ggj18f;

import org.newdawn.slick.GameContainer;
import org.newdawn.slick.Graphics;
import org.newdawn.slick.Image;
import org.newdawn.slick.SlickException;
import org.newdawn.slick.state.BasicGameState;
import org.newdawn.slick.state.StateBasedGame;

public class Splash extends BasicGameState
{
    private Main main;
    private Image splash;
    private int p = 0;
    private boolean boi = true;

    public Splash(Main main)
    {
        this.main = main;
    }

    @Override
    public int getID()
    {
        return 0;
    }

    @Override
    public void init(GameContainer gameContainer, StateBasedGame stateBasedGame) throws SlickException
    {
        splash = new Image("assets/splash.jpg");
    }

    @Override
    public void render(GameContainer gameContainer, StateBasedGame stateBasedGame, Graphics graphics) throws SlickException
    {
        splash.draw(0, 0, gameContainer.getWidth(), gameContainer.getHeight());
    }

    @Override
    public void update(GameContainer gameContainer, StateBasedGame stateBasedGame, int i) throws SlickException
    {
        if(p < Holder.links.size())
        {
            Holder.images.add(new Image(Holder.links.get(p)));
            p++;
        }
        else
        {
            if(boi)
            {
                main.addState(new Game(main));
                main.getState(1).init(gameContainer, main);
                main.enterState(1);
            }
        }
    }
}
