5. Our own TMXMapLoader

LibGDX comes with a set of classes to load tile maps made with Tiled, but those are too advanced for my needs right now and use unnecessarily many resources. First we will create a nice map in Tiled! consisting of:

That part is no longer valid. When I did a test with the default TMXMapLoader and Renderer I had a serious case of performance drops but somehow they are not that big this time. It is actually worth the ease of world creation.

The map I created consists of the following layers:

  • Background, which does not change
  • Foreground, which contains things like tree trunks and cannot be walked through
  • Top layer(s), which contains the other parts of trees but overlap other stuff

In earlier examples I used 16x16 tiles, but I now use 32x32 because it makes our world nicer, in my opinion.  The background layer consists of the path, grass and rocky path. The Foreground layer consists of all the tree trunks and the top layer consists of the other tree parts.

Simple Tiled world

Now we need some way to define collision as well, because of the large amount of work I will postpone this to the next post.

I also changed the way enemies look, created a heatmap (manually, large pain in the ...) and cleaned up some of my code now that I can use the default TiledMap from LibGDX.

comments powered by Disqus