Skip to content

How to use Gamelib in your project

Gamelib is available in the KPI Maven repository.

To use it with Gradle build tool, add the following repository to the build.gradle.kts file:

repositories {
    maven(url = uri("https://repo.kpi.fei.tuke.sk/repository/maven-releases"))
}

Gamelib consists of the following modules:

  • gamelib-core - Base module built as a wrapper on top of LibGDX. If you want to create a game from scratch, this package alone will suffice, alongside one of the gamelib-backend-* modules.
  • gamelib-framework - Module that provides simplified creation of actors and actions through abstract classes, contains a simple player actor and an inspectable world (by relying on gamelib-inspector module).
  • gamelib-inspector - Internal module integrating graphical Inspector tool to ease first steps in the OOP world for students. This module is not usable on its own as a game library. It is included in gamelib-framework module and can be used with gamelib-core if needed.
  • gamelib-backend-* - Internal module providing graphical backend for the gamelib-core. Currently available are the gamelib-backend-lwjgl (LWJGL3 backend) and gamelib-backend-lwjgl2 (LWJGL2 backend).

gamelib-core

The gamelib-core module can be used as a library for creating a game from scratch. It contains mostly interfaces for basic game-building blocks, but provides functional implementations of graphical elements like scenes and animations.

The module should be used alongside one of the gamelib-backend-* modules that will provide graphical backend implementation.

To use this module, add the following to build.gradle.kts to dependencies block:

dependencies {
    implementation("sk.tuke.kpi.gamelib:gamelib-core:2.6.1")
    implementation("sk.tuke.kpi.gamelib:gamelib-backend-<<backend>>:2.6.1")
}

where <<backend>> should be replaced with lwjgl for LWJGL3 and lwjgl2 for LWJGL backends. You can then use either LwjglBackend or Lwjgl2Backend classes for backend in the GameApplication constructor.

gamelib-framework

If you want to start working on a game with a bit of help, you can choose gamelib-framework module that includes all of gamelib-core functionality, but adds common logic for actors and actions. It also provides a graphical tool for inspecting and manipulating with objects creating the game.

To use this module, add the following to build.gradle.kts to dependencies block:

dependencies {
    implementation("sk.tuke.kpi.gamelib:gamelib-framework:2.6.1")
    implementation("sk.tuke.kpi.gamelib:gamelib-backend-<<backend>>:2.6.1")
}

where <<backend>> should be replaced with lwjgl for LWJGL3 and lwjgl2 for LWJGL backends. The framework will automatically load the backend available on the classpath.

Module gamelib-core does not need to be included explicitly when using gamelib-framework.

gamelib-inspector

Use gamelib-inspector in combination with gamelib-core if you want the graphical game-inspecting tool. To use it, add the following to build.gradle.kts to dependencies block:

dependencies {
    implementation("sk.tuke.kpi.gamelib:gamelib-inspector:2.6.1")
}

To use inspector’s functionality, you can use InspectableScene wrapper class:

// create a usual scene - e.g., with default World class
var world = new World("my-map.tmx", new MyGameActorFactory());

// wrap it in InspectableScene that integraties with inspecting tool
var inspectableWorld = new InspectableScene(world, List.of("my.game.package"));

// add inspectable scene to your game
game.addScene(inspectableWorld);