Difference between revisions of "Basic Setup"

From Slick2D Wiki
Jump to: navigation, search
Line 12: Line 12:
 
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!
+
7.Now we'll try running a very simple game! The point of the game will be checking if our setup succeeded! <br />
 
Create a main class includes the following:
 
Create a main class includes the following:
<code>
+
<pre>
 
package simpleslickgame;
 
package simpleslickgame;
 
import java.util.logging.Level;
 
import java.util.logging.Level;
Line 55: Line 55:
 
}
 
}
 
}
 
}
</code>
+
</pre>
 +
8.If everything went smooth, cheer harder.

Revision as of 06: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);
		}
		
	}
}

8.If everything went smooth, cheer harder.