0

Hi I am trying to make a java game using slick2D and lwjgl 2.8.4. But I am not being able to implement AppGameContainer class. It causes a run time error. My code is given below:

  import org.newdawn.slick.AppGameContainer;
  import org.newdawn.slick.BasicGame;
  import org.newdawn.slick.GameContainer;
  import org.newdawn.slick.Graphics;
  import org.newdawn.slick.SlickException;


  public class Main extends BasicGame{

   public Main(String title) {
    super(title);
    // TODO Auto-generated constructor stub
   }




   public static void main(String args[]) throws SlickException{
    AppGameContainer app = new AppGameContainer(new Main("Tower Defence"));
    app.setDisplayMode(800, 600, false);
        app.start();

   }

   @Override
   public void render(GameContainer container, Graphics g)
        throws SlickException {
    // TODO Auto-generated method stub

   }

   @Override
   public void init(GameContainer container) throws SlickException {
    // TODO Auto-generated method stub

   }

   @Override
   public void update(GameContainer container, int delta)
        throws SlickException {
    // TODO Auto-generated method stub

   }

  }

Then I get the following run time error: enter image description here

my package explorer in eclipse is given below:

enter image description here

How can I avoid this error?

shaonAshraf
  • 1,107
  • 1
  • 11
  • 21

2 Answers2

0

The graphics card driver was not installed. Installation of the graphics card driver solved the problem.

shaonAshraf
  • 1,107
  • 1
  • 11
  • 21
0

Try this:

public static void main(String[] args) {

    AppGameContainer app;

    try {

        app = new AppGameContainer(new Main("Tower Defence"));
        app.setDisplayMode(800, 600, false);
        app.start();

    } catch (SlickException e) {

        e.printStackTrace();

    }

}

That's how I always structure mine.

Michael Curry
  • 991
  • 8
  • 20