Setting Up Slick2D

Exclusive offer: get 50% off this eBook here
Slick2D Game Development

Slick2D Game Development — Save 50%

Develop simple, yet engaging games with the Slick2D game engine with this book and ebook

$17.99    $9.00
by Jacob Bevilacqua | October 2013 | Games Open Source

In this article by Jacob Bevilacqua, the author of Slick2D Game Development, we will look into:

  • What is Slick2D?
  • Downloading the Slick2D and LWJGL files
  • Setting up an eclipse project
  • Native files
  • What if I want my game to be platform-specific?

(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:


Slick2D Game Development Develop simple, yet engaging games with the Slick2D game engine with this book and ebook
Published: October 2013
eBook Price: $17.99
Book Price: $29.99
See more
Select your format and quantity:

About the Author :


Jacob Bevilacqua

Jacob Bevilacqua is a student who works on open source projects as well as game development projects in his free time. He has worked on several open source projects and has started one himself. Jacob is proficient in Java and Java game development, using both Slick2D and LibGDX.

Books From Packt


CryENGINE 3 Game Development: Beginner's Guide
CryENGINE 3 Game Development: Beginner's Guide

Cocos2d for iPhone 1 Game Development Cookbook
Cocos2d for iPhone 1 Game Development Cookbook

3D Game Development with Microsoft Silverlight 3: Beginner's Guide
3D Game Development with Microsoft Silverlight 3: Beginner's Guide

Learning Libgdx Game Development
Learning Libgdx Game Development

Flash Game Development by Example
Flash Game Development by Example

HTML5 Game Development with GameMaker
HTML5 Game Development with GameMaker

Learning Windows 8 Game Development
Learning Windows 8 Game Development

Cocos2d-X by Example Beginner's Guide
Cocos2d-X by Example Beginner's Guide


Code Download and Errata
Packt Anytime, Anywhere
Register Books
Print Upgrades
eBook Downloads
Video Support
Contact Us
Awards Voting Nominations Previous Winners
Judges Open Source CMS Hall Of Fame CMS Most Promising Open Source Project Open Source E-Commerce Applications Open Source JavaScript Library Open Source Graphics Software
Resources
Open Source CMS Hall Of Fame CMS Most Promising Open Source Project Open Source E-Commerce Applications Open Source JavaScript Library Open Source Graphics Software