Slick Applet

I’m trying to make my Slick game an applet, but it keeps giving me an error whenever I have a line like this:

if (app.getInput().isKeyDown(Input.KEY_W)) {

YES! My moment of glory:

;D

My apologies :slight_smile:

Mon Dec 19 19:25:29 EST 2011 INFO:Slick Build #274
Mon Dec 19 19:25:29 EST 2011 INFO:Starting display 1024x768
Mon Dec 19 19:25:29 EST 2011 INFO:Controllers not available
Test 1
Mon Dec 19 19:25:29 EST 2011 INFO:Initialising sounds..
Mon Dec 19 19:25:29 EST 2011 INFO:- Sound works
Mon Dec 19 19:25:29 EST 2011 INFO:- 64 OpenAL source available
Mon Dec 19 19:25:29 EST 2011 INFO:- Sounds source generated
Test 2
Mon Dec 19 19:25:30 EST 2011 ERROR:null
java.lang.NullPointerException
	at com.theducecat.pong.Pong.update(Pong.java:96)
	at org.newdawn.slick.GameContainer.updateAndRender(GameContainer.java:657)
	at org.newdawn.slick.AppletGameContainer$Container.runloop(AppletGameContainer.java:514)
	at org.newdawn.slick.AppletGameContainer$ContainerPanel.start(AppletGameContainer.java:218)
	at org.newdawn.slick.AppletGameContainer$1.run(AppletGameContainer.java:92)
org.newdawn.slick.SlickException: Game.update() failure - check the game code.
	at org.newdawn.slick.GameContainer.updateAndRender(GameContainer.java:663)
	at org.newdawn.slick.AppletGameContainer$Container.runloop(AppletGameContainer.java:514)
	at org.newdawn.slick.AppletGameContainer$ContainerPanel.start(AppletGameContainer.java:218)
	at org.newdawn.slick.AppletGameContainer$1.run(AppletGameContainer.java:92)

Ok so it should be quite obvious that either “app” or “app.getInput()” return null.

It works fine when I run it as an application, and I’m pretty sure it said to leave it as an AppGameContainer as Slick will make it an AppletGameContainer.