Getting Started

I want to start making simple games with the Slick API. How easy is it to make something simple and fun at the same time? Any tutorials would be great :wink:

I eventually want to be making a simple 2d like mmorpg thing. So I will be working my way up from simple games.

Its pretty simple to start making stuff with slick. The best place to start is to use the tons of example tests that slick comes with. Just have a look at how its done in the examples or better use them as a starting point to build your game on. They will really help you get going.

If you need further help you can also try the slick or lwjgl irc channels, you will usually find lots of helpful people there that’ll help you through any problems.

Yeah I do need help, I downloaded the slick src but don’t know how to import it to eclipse, and I don’t know what the IRC channels are.

Edit: I think I figured out how to import it to eclipse.

If you don’t want to modify the source, you can just use the slick-jar-file. Place it somewhere in your project folder and add it in eclipse via project-properties -> java build-path -> libraries -> add.

I did that already. I’m trying to figure out if this is a better framework, or if lwjgl is better. They had an example on their site, and it looked easy. I don’t know how to get started with Slick :(. I just want to start making a basic game :stuck_out_tongue:

In order to get slick running you need to

  1. import the external jars slick.jar and lwjgl.jar into eclipse
  2. add a vm argument which points to the path where lwjgl’s native dll files are located.

Thats the tricky bit, once done you should be on your way.

So I need both Slick and lwjgl to do games?

Yes. LWJGL is a simple binding to OpenGL, OpenAL and JInput, so it gives you raw access to the OpenGL API.

Slick on the other hand is a 2d framework/library built on top of LWJGL that allows easy production of 2d games. It contains all the stuff you need like texture loader (png, tga, etc), sound loader(wav, ogg, etc), music loader(ogg, mod, etc), font support, tiledmap and much more, all of which you would have to write yourself if you plan to use plain LWJGL.

I just wrote a ā€œSlick+Eclipseā€ tutorial, which you may find useful. It only goes as far as configuration and a ā€œHello, Worldā€ application, but maybe it’s enough to help you get the libraries set up.

http://www.cs.bsu.edu/homepages/pvg/misc/slick_eclipse_tutorial.php

Ok if I link the tutorial into the Slick Wiki?

Kev

The tutorial looks nice, but I get this error:

Exception in thread ā€œmainā€ java.lang.Error: Unresolved compilation problems:
AppGameContainer cannot be resolved to a type
AppGameContainer cannot be resolved to a type

at edu.bsu.slicktest.SimpleTest.main(SimpleTest.java:1)

I fixed that error, you forgot to import org.newdawn.slick.*;

but you also didn’t import org.lwjgl.*; which I did just now. I get the following error:

Exception in thread ā€œmainā€ java.lang.UnsatisfiedLinkError: no lwjgl in java.library.path
at java.lang.ClassLoader.loadLibrary(Unknown Source)
at java.lang.Runtime.loadLibrary0(Unknown Source)
at java.lang.System.loadLibrary(Unknown Source)
at org.lwjgl.Sys$1.run(Sys.java:75)
at java.security.AccessController.doPrivileged(Native Method)
at org.lwjgl.Sys.doLoadLibrary(Sys.java:68)
at org.lwjgl.Sys.loadLibrary(Sys.java:84)
at org.lwjgl.Sys.(Sys.java:101)
at org.lwjgl.opengl.Display.(Display.java:111)
at org.newdawn.slick.AppGameContainer$1.run(AppGameContainer.java:38)
at java.security.AccessController.doPrivileged(Native Method)
at org.newdawn.slick.AppGameContainer.(AppGameContainer.java:35)
at edu.bsu.slicktest.SimpleTest.main(SimpleTest.java:26)

that error means you haven’t got the native libraries configured properly (try step 4 again). Make sure the path is correct. Also remember if on windows to use ; instead of : in the path.

where do you use ; instead of : in windows path!?

anyway, as you are working with eclipse, just find lwjgl.jar library in your project and expand it, select natives and select a directory where natives are (usually you need to extract natives-windows/mac/linux as they are in a .jar file and you must point to a directory with files unpacked)

MKova awesome! You explained it the best :stuck_out_tongue:

It works now :smiley:

So, now I’ve gotta play with this and see what I can do. Anyone have any other tutorials that you recommend?

Please feel free. I hope it is found useful.

I’ll point out that, within Eclipse, one can edit the Properties of a jar (such as lwjgl.jar) and set the native paths for that library. However, I advise against this since it can cause problems when developing on multiple platforms. I develop and test in Linux and Windows, but all the code is shared in one repository. I would rather not have to change all my jars’ properties each time I hop between operating systems, so instead, my tutorial advises the reader to use command-line arguments (-Djava.library.path=…).

Well there should not be problems with that as all those properties and added classpaths are stored in .classpath file with is a xml file with data.

Example of lwjgl native location entry in .classpath




I did not check if it works on linux but I can’t see why it shouldn’t.

I mean for the native libraries. You’re right that the classpath is fine, but last I checked, if you associate a native library folder with a jar via Eclipse’s ā€œpropertiesā€ dialog, then upload your project to subversion, hop to another operating system, and pull down the code from subversion, it will remember the old native libs. Now that I think about it, you could probably get around this by putting /all/ your native libraries in one big folder. This had not dawned on me before since I like to use separate folders for each platform, as this helps me write more clear ant scripts that generate platform-specific resource jars. If anyone has tried this, I’d be curious to know if it worked.

All native libs in one folder, that’s what I’m doing, but I have not got the chance to test it yet on operating systems other than Win XP

Can Anyone explain to me how to include the Slick library in Apple’s Xcode tools?