# Working with Hex-based maps

**URL:** <https://discourse.mapeditor.org/t/working-with-hex-based-maps/2941>\
**Category:** Questions\
**Created:** [January 18, 2018, 8:46am UTC](https://discourse.mapeditor.org/t/working-with-hex-based-maps/2941 "2018-01-18T08:46:15Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![TJ\_Redleg](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.mapeditor.org/tj_redleg/32/817_2.png) [@TJ\_Redleg](https://discourse.mapeditor.org/u/TJ_Redleg)\
**Post date:** [January 18, 2018, 8:46am UTC](https://discourse.mapeditor.org/t/working-with-hex-based-maps/2941/1 "2018-01-18T08:46:15Z")

</div>

I want to use Tiled to create a hex-based wargame map, the kind you find in “analog” or boxed wargames. There are certain tasks associated with such maps for example:

- Determining line of sight
- Determining range or distance

Question:  
Are there routines that come with Tiled that would allow me to do these calculations?

I’ve done some searching but couldn’t find anything to indicate there is, so my second question is:

Is there a library that supports the functionality I’m looking for?

Any help would be greatly appreciated.

Thanks,

TJ

---

<div class="post-metadata">

**Author:** ![darkhog](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.mapeditor.org/darkhog/32/1563_2.png) [@darkhog](https://discourse.mapeditor.org/u/darkhog)\
**Post date:** [January 18, 2018, 12:37pm UTC](https://discourse.mapeditor.org/t/working-with-hex-based-maps/2941/2 "2018-01-18T12:37:01Z")

</div>

No, Tiled is purely a map editor. Any game features such as distance checking needs to be implemented in the game itself.

---

<div class="post-metadata">

**Author:** ![TJ\_Redleg](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.mapeditor.org/tj_redleg/32/817_2.png) [@TJ\_Redleg](https://discourse.mapeditor.org/u/TJ_Redleg)\
**Post date:** [January 22, 2018, 12:56pm UTC](https://discourse.mapeditor.org/t/working-with-hex-based-maps/2941/3 "2018-01-22T12:56:20Z")

</div>

Let’s say I wanted to add hex-based functionality. Are there any files I would need from the map editor as a starting point?

I wouldn’t do it myself I don’t have the skills but I need this functionality for a project. I’m seriously considering paying someone to do this for me.

I think a lot of the code is done:

> **[Red Blob Games: Hexagonal Grids](https://www.redblobgames.com/grids/hexagons/)**
>
> Guide to math, algorithms, and code for hexagonal grids in games

But I have no clue on where to begin to make this work with a Tiled map.

Any thoughts on how I should proceed?

---

<div class="post-metadata">

**Author:** ![bjorn](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.mapeditor.org/bjorn/32/1599_2.png) [@bjorn](https://discourse.mapeditor.org/u/bjorn)\
**Post date:** [January 22, 2018, 8:44pm UTC](https://discourse.mapeditor.org/t/working-with-hex-based-maps/2941/4 "2018-01-22T20:44:01Z")

</div>

The hexagonal maps supported by Tiled are the four variants of what that article calls [Offset Coordinates](https://www.redblobgames.com/grids/hexagons/#coordinates-offset) (in Tiled I called it “Hexagonal (Staggered)”).

Once you know how to [convert the coordinates](https://www.redblobgames.com/grids/hexagons/#conversions-offset) (and Tiled has some code for this as well: `src/libtiled/hex.h` defines a `Hex` class that represents a hex [cube coordinate](https://www.redblobgames.com/grids/hexagons/#coordinates-cube)), you can use the other algorithms explained on that website to implement [distance](https://www.redblobgames.com/grids/hexagons/#distances) or [field of view](https://www.redblobgames.com/grids/hexagons/#field-of-view) calculations.

Of course @darkhog is right that Tiled is just an editor. If you need to have this functionality available as a tool inside Tiled, for use during editing, then I can help you. But if you need it to be available in your game, then it will need to be implemented there. I do not know of a library that helps you with this, but maybe there is.

---

<div class="post-metadata">

**Author:** ![TJ\_Redleg](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.mapeditor.org/tj_redleg/32/817_2.png) [@TJ\_Redleg](https://discourse.mapeditor.org/u/TJ_Redleg)\
**Post date:** [January 23, 2018, 5:54am UTC](https://discourse.mapeditor.org/t/working-with-hex-based-maps/2941/5 "2018-01-23T05:54:55Z")

</div>

Bjorn,  
If you could implement this functionality in the editor that would be great, not sure how popular it would be. The kind of games I’m interested in require such functionality.

As far as in-game functions go I will look for some local talent, maybe they can help. I do not have the skills to do it on my own.

Yeah I know it’s just an editor but I figure someone could point me to a “hex” lib that works with Tiled.
