Skip to main content

Darek Greenly

Personal blog, expect game dev and web stuff

Auto Terrain Generator for Tiled

Intro

During development of GrayScale I found myself lacking the tools or skill to create terrain in Tiled editor. Using terrains I could create pretty maps much faster than placing individual tiles for details. Now with Auto Terrain Generator I can actually focus on doing some level design.

Demo

Download

Just let me download it already!

https://github.com/Zielak/AutoTerrainGen/releases

GitHub

Download: https://github.com/Zielak/AutoTerrainGen/releases

Get the source code and play with it: https://github.com/Zielak/AutoTerrainGen

I’m open for PRs and fixing issues. I’m working only on Linux and Windows so It would be cool to see someone build this tool without problem on a Mac :)

How to use

Use this tool to combine your layers into one terrain and paint quicker landscape in Tiled editor.

1. Prepare your tilesets

Each tileset should contain every possible tile combination. Use below template to create your own. Only 15 tiles are used, the last one is ignored.

I’ve tested this tool for generating terrain of 2, 3 and 4 tilesets. Adding more would probably cause longer generation time, and also I’m not sure how would Tiled react to that.

template tileset

Terrain Generator - Template tileset

2. Set correct tile size

Open the generator and set your tile size. Default is 16px x 16px. Change it in “Configurate” window if you’re using different tile size. Width and height must be equal, eg. 32px x 32px.

3. Load up all your tilesets

Put all your tilesets into input folder (next to the program executable), type your filename in generator (with an extension!) and hit LOAD. Your tileset should appear in the list below.

Now you can:

  • change name of the layer - this will appear in Tiled Terrains window (hover your mouse over text input to start typing, don’t move cursor away from text input!)
  • change order - bottom layers will be rendered on top of all the other tilesets. Reverse-photoshop style :)
  • remove tileset with “remove” button
  • preview tileset by clicking an image to see how the generator split each tile in “Tileset Preview” window

Load tileset

Terrain generator - Load tileset

4. Hit GENERATE!

The terrain will be available to preview in the right part of window.

5. Export bitmap and TSX file

At the bottom you’ll find:

  • “Export Bitmap” - save terrain PNG file in output/ folder
  • “Export TSX” - save .tsx file for Tiled in the same folder

Work in Tiled

Now you can move both files from Auto Terrain Generator folder to your own game. To use your new terrain you have to open new map in Tiled, go to menu and hit “Map” -> “Add external tileset”. Navigate to generator’s output/ folder and choose output.tsx file.

This tool was created using:

  • luxe engine - luxe is a free, open source cross platform rapid development Haxe based game engine for deploying games on Mac, Windows, Linux, Android, iOS and WebGL.
  • mint - mint is minimal, renderer agnostic ui library for Haxe.
  • format - The format library contains support for different file-formats for the Haxe programming language.

[commits repository=‘AutoTerrainGen’ count=‘5’ title=‘Commits’]

Comments