I recently started trying to work with outside Java libraries like Slick2D. This is my first time doing so, so I basically have no clue what I am doing.
I tried making a simple StateBasedGame that only displays a menu bar showing three options. The problem is that in my 'Game' class, the initStatesList() method isn't being called and I don't know why not. Here's the code:
Game class
import org.newdawn.slick.GameContainer;
import org.newdawn.slick.SlickException;
import org.newdawn.slick.state.StateBasedGame;
public class Game extends StateBasedGame {
public Game(String title) {
super(title);
}
public static void main(String[] args) {
Game game = new Game("Text Based");
}
@Override
public void initStatesList(GameContainer arg0) throws SlickException {
System.out.println("InitStates");
addState(new Menu());
}
}
Menu class:
import org.newdawn.slick.Color;
import org.newdawn.slick.GameContainer;
import org.newdawn.slick.Graphics;
import org.newdawn.slick.SlickException;
import org.newdawn.slick.state.BasicGameState;
import org.newdawn.slick.state.StateBasedGame;
public class Menu extends BasicGameState {
private int ID = 1;
@Override
public void init(GameContainer arg0, StateBasedGame arg1) throws SlickException {
}
@Override
public void render(GameContainer container, StateBasedGame game, Graphics g) throws SlickException {
g.setColor(Color.white);
g.drawString("Higher or Lower", 50, 10);
g.drawString("1. Play Game", 50, 100);
g.drawString("2. High Scores", 50, 120);
g.drawString("3. Quit", 50, 140);
}
@Override
public void update(GameContainer arg0, StateBasedGame arg1, int arg2) throws SlickException {
}
@Override
public int getID() {
return ID;
}
}
I have no clue why it doesn't work...