pablogila / TileMapDual_godot_node

An automatic, real-time dual-grid tileset system for Godot
MIT License
206 stars 8 forks source link

TileMapDual Godot Node

Introducing TileMapDual: a simple, automatic and straightforward custom TileMapLayer node for Godot that provides a real-time, in-editor and in-game dual-grid tileset system, for both square and isometric grids.

This dual-grid system, as explained by Oskar Stålberg, reduces the number of tiles required from 47 to just 15 (yes, fifteen!!), rocketing your dev journey!

Not only that, but if your tiles are symmetrical, you can get away with drawing only 6 (six!) tiles and then generating the 15-tile-tilesets used by TileMapDual, thanks to tools like Wang Tile Set Creator.

Advantages

Using a dual-grid system has the following advantages:

Installation and usage

Just copy TileMapDual.gd from the scripts folder to your project to start using the new custom node.

You have to create a TileMapDual node with your own 2x2 tileset, following the standard godot tileset. And that's it! You can now start sketching your level with the fully-filled tile, indicated here:

You can also sketch with the empty tile in the bottom-left corner, or erase tiles as usual. The dual grid will update in real time as you draw!

An example with a square tileset is provided in the Jess scene.

You can modify the dual tileset in-game by calling the following methods. An example is included in the custom CursorDual node.

An additional method, TileMapDual.update_full_tileset(), is available to refresh the entire dual grid. It should not be necessary, but may come in handy in case of a hypothetical bug.

Isometric tilesets

Isometric tilemaps are now compatible with the TileMapDual node.
You heard that right, isometric, as in 'isometric'. It works automatically, out of the box. Isometric tilemaps! yayyyy!

An use example is provided in the Isometric scene.

To use isometric tilemaps, you only need to follow an isometric-ed version of the standard godot tileset template that we previously used for square tilemaps. Here it is:

This isometric tileset can be drawn by hand. But it can also be drawn more easily using a tool like IsoMapper. This Godot plugin allows you to draw the tiles in one continuous image, to later separate the tiles as shown in the image below.

(NOTE: IsoMapper is still under development, and any contribution in the GitHub repo is really appreciated!)

That's it. Just 15 tiles for isometric autotiling. I love it.

Multiple atlases and layers

You can use multiple atlases in the same tileset. To change them in-game, make sure you call the fill_tile and erase_tile methods described above with the desired atlas_id, which is 0 by default. An example is included with the custom CursorDual node, see the MultipleAtlases scene.

Note that each atlas can handle 2 surfaces. To add more surfaces or tile variations on top of one another, consider using a second TileMapDual node with transparencies in your tileset, just as you would do with a regular TileMapLayer. An example is provided in the MultipleLayers scene.

Why?

This release simplifies the implementation of a dual-grid system by introducing a simple custom node that runs automatically and in-editor, making it easy to integrate into your own projects.

Previous implementations of a dual-grid tileset system in Godot, mainly by jess::codes and GlitchedInOrbit, were not automatic and required extensive manual configuration (at the time of writing). These implementations also used an inverted version of the standard 16-tile template (although Jess's tileset is provided as an example in this repo). This is a potential source of headaches, and this release corrects said inversion.

This release also implements modern TileMapLayers instead of the deprecated TileMap node.

Plus, you can use multiple atlases in the same tileset.

Oh, and also... You can use isometric tilesets!

To-do

License and contributing

This project is Open Source Software, released under the MIT license. This basically means that you can do whatever you want with it. Enjoy!

This repo is open to pull requests, just make sure to check the contributing guidelines. I personally encourage you to send back any significant improvements to this code so that the Godot community continues to thrive. Thanks!

References

Feedback

Please feel free to contact me to provide feedback, suggestions, or improvements to this project. You may also check the the contributing guidelines to submit an issue or a pull request :D