3 min read

(For more resources related to this topic, see here.)

What is Slick2D?

Slick2D is a multi-platform library for two dimensional game development that sits upon the LWJGL(Light-Weight Java Game Library). Slick2D simplifies the processes of game development such as game loop, rendering, updating, frame setup, and state-based game creation. It also offers some features that LWJGL does not, such as particle emitters and integration with Tiled (a map editor).

Developers of all skill levels can enjoy Slick2D, as it offers a degree of simplicity that you can’t find in most libraries. This simplicity not only makes it a great library for programmers but artists as well, who may not have the technical knowledge to create games in other libraries.

Downloading the Slick2D and LWJGL files

The Slick2D and LWJGL jar files, plus the LWJGL native files, are needed to create a Slick2D game project. The only system requirement for Slick2D is a Java JDK. To get the files, we perform the following steps:

  1. Obtaining the LWJGL files:
    1. Navigate to http://www.lwjgl.org/download.php.
    2. Download the most recent stable build.
    3. The .zip file will include both the LWJGL jar file and the native files. (This .zip file will be referenced as lwjgl.zip file.)
  2. Obtaining the Slick2D files:
    1. Due to hosting issues, the Slick2D files are being hosted by a community member at http://slick.ninjacave.com. If this site is not available, follow the alternative instructions at step 3.
    2. Click on Download.
  3. Alternative method of obtaining the Slick2D files:
    1. Navigate to https://bitbucket.org/kevglass/slick.
    2. Download the source.
    3. Build the ant script located at slick/trunk/Slick/build.xml
    4. Build it in eclipse or command line using $ ant.

Setting up an eclipse project

We will utilize the Eclipse IDE that can be found at http://www.eclipse.org/ when working with Slick2D in this article. You may, however, utilize other options.

Perform the following these steps to set up a Slick2D project:

  1. Navigate to File | New | Java Project.
  2. Name your project and click on Finish.
  3. Create a new folder in your project and name it lib.
  4. Add two subfolders named jars and native.

  5. Place both lwjgl.jar and slick.jar in the jars subfolder inside our eclipse project.
  6. Take all the native files from lwjgl.zip and place them in the native subfolder.

    Copy the contents of the subfolders inside native from lwjgl.zip not the subfolders themselves.

  7. Right-click on project then click on Properties.
  8. Click on Java Build Path and navigate to the Libraries tab.
  9. Add both the jars from the project.

  10. Select and expand lwjgl.jar from the Libraries tab and click on Native library location: (None) then click on Edit and search the workspace for the native’s folder.

Native files

The native files included in lwjgl.zip are platform-specific libraries that allow the developers to make one game that will work on all of the different platforms.

What if I want my game to be platform-specific?

No real benefit exists to being platform-specific with Slick2D. In the foregoing tutorial, we will establish a game as a multi-platform game. However, if you want your game to be platform-specific, you can make it platform-specific. In the previous tutorial (step 6) we took the content of each operating system’s folder and put that content into our native folder. If, instead, you desire to make your game platform-specific, then instead of copying the contents of these folders, you would copy the entire folder as illustrated as follows:

When defining the natives for LWJGL (step 10 in previous example), simply point towards the operating system of your choice.

Summary

In this article we learned tons of important things necessary to create a project in Slick2D. So far we covered:

  • Downloading the necessary library files
  • Setting up a project (platform-specific or multi-platform)
  • Native files

Resources for Article:


Further resources on this subject:


LEAVE A REPLY

Please enter your comment!
Please enter your name here