Java – The most efficient way to create game levels? (LibGDX)

The most efficient way to create game levels? (LibGDX)… here is a solution to the problem.

The most efficient way to create game levels? (LibGDX)

I’m making a platformer-like game (not exactly a platformer; It’s vertical scrolling), but the level loading should be similar. So far, I have come across two ways to create game levels.

  1. Use tile maps . Basically, you create a level in the Tiled Map Editor using some graph blocks, such as Tiled, and then use it as your level.

  2. Use ArrayList and store all GameObjects (brick blocks, spikes, etc.). All objects and their locations are stored in a text file, then used at runtime using StringTokenizer and iterating and placed into an array.

In my opinion, it is easier and more convenient to use Tiled Map. Are there any disadvantages to using Tiled Maps and/or using the ArrayList method? Or is there another better way?


The answer lies in your question: Tiled Maps are simpler and more convenient, while text files are harder and less convenient.

Instead of using custom-parsed text files, use standard formats such as XML or JSON. Goos parsers for these formats already exist.

If your question is about performance,

don’t worry, tiled is an XML format, and if you experiment with performance issues in the future, you can preprocess your tiled map to produce an optimized format for your game.

Related Problems and Solutions