Getting Started (1) – Setup a LITIengine Game Project

Tutorial - Getting Started With The LITIengine (Part 1) - Setup a Game Project

This part of the LITIengine tutorial series will guide you through the process of setting up your game project and getting all necessary libraries.

  1. Setup a LITIengine Game Project (this article)
  2. Learning the Basics
  3. https://litiengine.com/getting-started-configuring-the-game/Configuring the Game
  4. Loading a .tmx Map
  5. Working with Entities

This Tutorial series will guide you through the basic steps of how to create your first “Hello World” Game with the LITIengine. We’ll use Eclipse as an example IDE to help you better understand some steps of this process. At the end of this series, we’ll have a running Game with a controllable Player.


Setup a LITIengine Game Project

There are multiple paths we can choose from when creating a new project with the LITIengine. Since the library is distributed over the Maven Central Repository, you can grab the necessary .jar-file(s) from there by using your favorite build automation tool.

Gradle/Grails

apply plugin: 'java'

repositories {
  mavenCentral()
}

dependencies {
  compile 'de.gurkenlabs:litiengine:X.X.XX'
}

Apache Maven

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
  <modelVersion>4.0.0</modelVersion>
  <groupId>de.gurkenlabs.litiengine</groupId>
  <artifactId>hello-liti-maven</artifactId>
  <version>0.0.1-SNAPSHOT</version>
  <name>hello-liti-maven</name>
  <dependencies>
    <dependency>
      <groupId>de.gurkenlabs</groupId>
      <artifactId>litiengine</artifactId>
      <version>X.X.XX</version>
    </dependency>
  </dependencies>
</project>

We’ve created example projects for both gradle and maven which can be found here.

Manually Download the LITIengine library

If you don’t want to use a build/dependency automation tool, you can of course also download the required files directly from our Github Release Page.
Just download the litiengine-vX.X.X.zip file and extract it somewhere on your hard drive. We suggest creating a lib folder in your java project where you can store the unpacked engine library files.

For Eclipse

  • Navigate to Project Properties/Java Build Path/Libraries
  • Click Add JARs… and search for the litiengine-vX.X.X.jar file in your lib folder
  • Expand the litiengine-vX.X.X.jar library in the JARs and class folder on the build path tree
  • Also, add the lib folder as native library location
  • Apply the changes by clicking OK

Managing Native Libraries (optional)

Managing (and deploying) the native libraries is only necessary for Controller Support and Accessing the Steamworks library.

The LITIengine has some native dependencies that allow supporting Controller Input and access to Steamworks. In case you want to use these features, you can either use a build tool plugin (e.g.  the Gradle Natives Plugin) or get the native libraries from the downloadable LITIengine package.

Either way, you need to add the location of the natives to the .classpath of your project if you want to use the functionality when your Game is being run from within your IDE.

The following build.gradle file extracts all native libraries of the LITIengine to the ‘libs‘ folder upon calling gradle includeNatives

plugins {
  id 'com.stehno.natives' version '0.3.1'
}

natives {
  configurations = ['runtime']
  outputDir = 'libs'
}

apply plugin: 'java'
apply plugin: 'maven'

repositories {
  mavenCentral()
}

dependencies {
  compile 'de.gurkenlabs:litiengine:0.4.12'
}

Test the Project Configuration

After successfully setting up the dependencies it is time to write the first lines of code. The following class will initialize the Game .Upon calling the method Game.start() an empty window will be spawned that renders a black background and a title with the LITIengine logo.

package litiengineexample;

import de.gurkenlabs.litiengine.Game;

public class HelloLitiGame {

  public static void main(String[] args) {
    Game.init();
    Game.start();
  }
}

Make sure to replace the line package litiengineexample; with the name of the package that contains the HelloLitiGame class.

If you see the following window, you’ve setup everything correctly and are now ready to create some awesome 2D java games with the LITIengine!

Empty LITIengine Window

That’s all for this part of the tutorial. Stay tuned for part 2, where we’re gonna create and configure a Simple Game with the project we just set up.

Until then, have a great one!