Tuesday, December 29, 2015

LibGDX game jam - dev log #1


The LibGDX Game Jam is on!

In addition to using LibGDX for the coding, I'll be using Tiled (http://www.mapeditor.org/) for level design and Box2D (http://box2d.org/) for physics. For prototyping I'll be using some spritesheets from (http://kenney.nl/). If time permits, I'll work on some custom art assets later.

All the code will be posted on GitHub at https://github.com/stemkoski/LibGDX-Jam

The timing is great, as I've just finished writing Beginning Java Game Development with LibGDX, and this will be an excellent opportunity to build on the foundations presented by that book (source code from the book can be downloaded at http://www.apress.com/9781484215012). To get things up and running quickly, I'll be using (and improving) the following Java classes developed in the book:

  • BaseGame and BaseScreen. These are abstract classes that extend the LibGDX Game and Screen classes, respectively.
  • BaseActor. Extends the LibGDX Actor class, contains Texture data and collision Shape data (which we won't use, instead delegating collision handling to Box2D).
  • AnimatedActor. Extends the BaseActor class, contains Animation data. 
  • Box2DActor. Extends the AnimatedActor class, contains physics-related (Body) data for Box2D.
  • GameUtils. A utility class containing methods to simplify (1) creating animations from files, and (2) processing collisions from Box2D.
  • ParticleActor. Extends the Actor class, is useful for particle effects created with the LibGDX particle editor.


The theme for the LibGDX game jam is "Life in Space". My first thought was outer space -- planets, stars, rocketships, asteroids, etc. From a game design perspective, I've always had a great deal of respect for the classic arcade game Asteroids, for two reasons:

  • its use of immersion: the controls move the spaceship relative to its orientation, rather than relative to the screen directions
  • the shape of its universe: this game features wraparound (the left side of the screen is connected to the right; the top side of the screen is connected to the bottom), and so the Asteroids universe actually exists on the surface of a torus (the shape of a doughnut)

And this train of thought led me to my interpretation of the theme: a key gameplay mechanic is going to be the player figuring out the shape of the space they are in. There will be a series of rooms, but in this universe, they will not be connected as a flat grid. This game will be more puzzle/maze based rather than combat based.

The first step is going to be creating a data structure (called a Room) to hold tilemap data, physics objects, stage objects, etc. The current plan is for each map created with Tiled to have three layers: a tile image layer, a layer for interactive game objects (keys, doors, etc.), and a layer to store non-interactive physics objects (the walls). Each room will have an ID, a number of SpawnPoint objects (each with its own ID), and a number of Portal objects (which contain a destination room ID and spawn point ID). The main game will read in the Tiled TMX files, store each in a custom Room object, and store the set of Rooms in a HashMap (indexed by ID).

The images below show a room in Tiled, and as rendered in LibGDX.

a room in Tiled
room rendered in LibGDX

Working code that implements these steps is currently available on GitHub.