package org.egordorichev.lasttry;

import org.egordorichev.lasttry.util.Assets;
import org.lwjgl.util.Display;
import org.newdawn.slick.*;
import org.newdawn.slick.Graphics;
import org.newdawn.slick.Image;
import org.newdawn.slick.state.*;

import java.awt.*;

public class SplashState extends BasicGameState {
	private Image splash;
	private boolean loaded;

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

	@Override
	public void init(GameContainer gameContainer, StateBasedGame stateBasedGame) throws SlickException {
		this.splash = new Image("assets/images/splash" + LastTry.random.nextInt(6) + ".png");
		this.loaded = false;

		new Thread() {
			@Override
			public void run() {
				Assets.preload();
				loaded = true;
			}
		}.run();
	}

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

	@Override
	public void update(GameContainer gameContainer, StateBasedGame stateBasedGame, int i) throws SlickException {
		if(this.loaded) {
			stateBasedGame.addState(new GamePlayState());
			stateBasedGame.enterState(1);
		}
	}
}
@@ -566,16 +566,17 @@
 lash%22 + 
+(
 LastTry.
@@ -590,17 +590,22 @@
 nextInt(
-6
+5) + 1
 ) + %22.pn
@@ -1153,8 +1153,9 @@
 %09%09%7D%0A%09%7D%0A%7D
+%0A

Fix null pointer exception