0

I'm trying to run this code that is used to see if things were setup properly:

package simpleslickgame;
import java.util.logging.Level;
import java.util.logging.Logger;
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 SimpleSlickGame extends BasicGame
{
    public SimpleSlickGame(String gamename)
    {
        super(gamename);
    }

    @Override
    public void init(GameContainer gc) throws SlickException {}

    @Override
    public void update(GameContainer gc, int i) throws SlickException {}

    @Override
    public void render(GameContainer gc, Graphics g) throws SlickException
    {
        g.drawString("Howdy!", 10, 10);
    }

    public static void main(String[] args)
    {
        try
        {
            AppGameContainer appgc;
            appgc = new AppGameContainer(new SimpleSlickGame("Simple Slick Game"));
            appgc.setDisplayMode(640, 480, false);
            appgc.start();
        }
        catch (SlickException ex)
        {
            Logger.getLogger(SimpleSlickGame.class.getName()).log(Level.SEVERE, null, ex);
        }
    }
}

All of the Googling I've done has led me to checking the natives over and over and I"m pretty sure I've done it right. When I go to the libraries in this project's build path, JRE System library and Slick2D both say Native library location: .../windows/x64. I've tried just .../windows, and I've tried it with the JRE not having a native location. I followed two different tutorials on how to do this and I keep getting errors trying to run this simple code. Any help?

5antoro
  • 85
  • 1
  • 8
  • What's not working? I just copied your code and managed to run it just fine... – Ubica Dec 11 '14 at 22:31
  • Stupid of me to not include the stack trace. I'm not at my laptop now. But it was a java.Lang error. I don't remember – 5antoro Dec 11 '14 at 22:59

1 Answers1

0

basically what you need is to add slick.jar and lwjgl.jar to your build path and then right click your project >> open properties >> click on Java Build Path >> open Libraries tab >> expand JRE System Library >> click Native library location >> edit >> External Folder >> find ..\lwjgl-2.9.0\native\windows folder on your hard drive >> select it >> and you're done

g.drawString("Howdy!", 10, 10);

I would just move this string to some other location, cause it's showing over the FPS counter :)

EDIT:

you can use the natives from ..\slick\lib\natives-windows.jar.

open it with WinRAR or something and extract to a folder, then just set that folder to be your Native library location

Ubica
  • 1,011
  • 2
  • 8
  • 18
  • Where do I get the lwjgl-2.9.0? I just have a lwjgl zip. I'm using 3. Is that why it's not working you think? – 5antoro Dec 11 '14 at 22:56
  • well that's the last version I used, so I have it on my hard drive. it should work with any stable version... btw I found this on slick2d web site `Releases 03 June 2013 - Slick build 237 includes LWJGL 2.9.0.` – Ubica Dec 11 '14 at 22:58
  • Ahh, thank you. The Slick natives worked! Time to attempt to learn this stuff :) – 5antoro Dec 12 '14 at 04:03