Difference between revisions of "Basic Setup"

From Slick2D Wiki
Jump to: navigation, search
Line 1: Line 1:
==Basic Setup==
 
 
1.Download Slick2D from [http://slick.ninjacave.com/slick.zip here] and LWJGL from [http://lwjgl.org/download.php here]. <br />
 
1.Download Slick2D from [http://slick.ninjacave.com/slick.zip here] and LWJGL from [http://lwjgl.org/download.php here]. <br />
 
2.Create a library in your [http://en.wikipedia.org/wiki/Integrated_development_environment IDE], call it however you want! <br />
 
2.Create a library in your [http://en.wikipedia.org/wiki/Integrated_development_environment IDE], call it however you want! <br />
Line 7: Line 6:
 
6.Go to your project properties (yeah, the one you created with me) and add the natives path. But how? <br />
 
6.Go to your project properties (yeah, the one you created with me) and add the natives path. But how? <br />
  
== Adding natives in NetBeans ==
+
= Adding natives in NetBeans =
 
1.Right click your project -> properties <br />
 
1.Right click your project -> properties <br />
 
2.Select the ''run'' category. <br />
 
2.Select the ''run'' category. <br />
 
3.Enter the following into VMOptions: -Djava.library.path=<lwjgl-X.X path>/native/<linux|macosx|solaris|windows> (complete needed) <br />
 
3.Enter the following into VMOptions: -Djava.library.path=<lwjgl-X.X path>/native/<linux|macosx|solaris|windows> (complete needed) <br />
 
4.Cheer. <br />
 
4.Cheer. <br />
 +
 +
7.Now we'll try running a very simple game! The point of the game will be checking if our setup succeeded!
 +
Create a main class includes the following:
 +
<code>
 +
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);
 +
}
 +
 +
}
 +
}
 +
</code>

Revision as of 05:13, 21 June 2013

1.Download Slick2D from here and LWJGL from here.
2.Create a library in your IDE, call it however you want!
3.Include slick.jar (under the lib folder inside the slick.zip file), lwjgl.jar (under the jar folder inside the lwjgl.zip file) and lwjgl-util (again, under the jar folder inside the lwjgl.zip file).
4.Create a new project in your IDE and add the library you created.
5.Extract the native folder from the lwjgl.zip file.
6.Go to your project properties (yeah, the one you created with me) and add the natives path. But how?

Adding natives in NetBeans

1.Right click your project -> properties
2.Select the run category.
3.Enter the following into VMOptions: -Djava.library.path=<lwjgl-X.X path>/native/<linux|macosx|solaris|windows> (complete needed)
4.Cheer.

7.Now we'll try running a very simple game! The point of the game will be checking if our setup succeeded! Create a main class includes the following: 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); }

} }