I am trying to get keyboard input in a separate class so everything doesn't look as messy. I get the following error message
Exception in thread "main" java.lang.NullPointerException
at com.****.****.Menu.init(Menu.java:33)
at com.****.****.Main.initStatesList(Main.java:35)
at org.newdawn.slick.state.StateBasedGame.init(StateBasedGame.java:164)
at org.newdawn.slick.AppGameContainer.setup(AppGameContainer.java:393)
at org.newdawn.slick.AppGameContainer.start(AppGameContainer.java:317)
at com.****.****.Main.main(Main.java:27)
This is what I tried:
Menu Class where I load the methods
public class Menu extends BasicGameState{
KeyboardInput kbi;
public Menu(int state) {
}
@Override
public void init(GameContainer gc, StateBasedGame sbg) throws SlickException {
kbi.init();
}
@Override
public void render(GameContainer gc, StateBasedGame sbg, Graphics g) throws SlickException {
kbi.render();
}
@Override
public void update(GameContainer gc, StateBasedGame sbg, int delta) throws SlickException {
kbi.update();
}
@Override
public int getID() {
return 0;
}
}
KeyboardInput class
public class KeyboardInput {
public KeyboardInput() {
}
public void init() {
}
public void render() {
}
public void update() {
}
}