Giter Site home page Giter Site logo

Add support for hexagonal maps about tiled HOT 27 CLOSED

bjorn avatar bjorn commented on May 5, 2024
Add support for hexagonal maps

from tiled.

Comments (27)

maq777 avatar maq777 commented on May 5, 2024

I've made a very basic impl. of a hexagonal renderer. Basic stuff works. Please have a look at it: https://github.com/maq777/tiled and tell me what issues/fixes have the highest priority for an possible inclusion on upstream.

from tiled.

LearnCocos2D avatar LearnCocos2D commented on May 5, 2024

Hex maps have my vote. If I remember correctly hex maps were working some time back (around Tiled 0.5/0.6), at least there was an option for creating them.

from tiled.

bjorn avatar bjorn commented on May 5, 2024

@LearnCocos2D Hex maps have never worked in Tiled Qt, but there was experimental support for them in the Java version of Tiled.

The reason I've never merged @maq777 patch is mostly because I didn't like the implementation of the rendering, which I think is too inefficient. Of course, I expected to get around to doing a faster renderer sooner rather than later, but this hasn't been the case so far.

from tiled.

LearnCocos2D avatar LearnCocos2D commented on May 5, 2024

As long as it works editing hex maps would be great, even if it may be slow or inefficient. You can always optimize or rewrite it at a later time if it's not fundamentally broken or incomplete (ie no select, no tilesets - I have no idea what the hex renderer does and doesn't do).

from tiled.

maq777 avatar maq777 commented on May 5, 2024

@LearnCocos2D @bjorn F.Y.I. The impementation I provide is broken. Yes, it needs optimizations. But most of all it needs bug fixes. And the only feasible way to fix the selection problems is a completely new algorithm. I studied and found a new algorithm - unfortunately I didn't have the time to implement it (and now the theory is long forgotten).

from tiled.

bjorn avatar bjorn commented on May 5, 2024

@maq777 No worries, we're all looking for more time. Yet, maybe @LearnCocos2D is right that it would be better to have an implementation that is not fundamentally broken rather than no implementation at all. On the other hand I've added an incomplete staggered renderer which, even though it's optimized, does not support object layers because I hadn't figured out a good way of handling those yet, and that confuses people... :-/

In any case, my approach would be to tweak the current staggered renderer to also work for hexagonal, since the rendering method is very similar. However, a solution will still need to be found for the object layers. I think the objects should use pixel coordinates for these types of maps and just ignore the projection (since the projection is irregular anyway).

from tiled.

nalmeth avatar nalmeth commented on May 5, 2024

I would love to have Tiled support hexes. Many other applications I've looked into that support them are old and/or terrible. Please make this feature a priority. Thanks for your work so far.

from tiled.

Goutte avatar Goutte commented on May 5, 2024

I love that this is the first issue !
This is something that would make me find a use for tiled ! (i got no time to pitch in right now, though)

In case some of you don't know about this yet, here's the new reference for hexagonal tiling : http://www.redblobgames.com/grids/hexagons/

The barycentric coordinates system is the way to go !

from tiled.

bjorn avatar bjorn commented on May 5, 2024

@Goutte Thanks a lot for linking that article, it's very useful! However, the article does not mention a "barycentric coordinates sytem". Is it mentioned under a different name? The article actually recommends its "axial coordinates", which seem to make sense to me.

However, if any such alternative coordinate systems are to be supported it needs to be done in addition to supporting the "offset" coordinates, since that is the system supported by the old Tiled Java and is what cocos2d-iphone supports.

from tiled.

Goutte avatar Goutte commented on May 5, 2024

Axial coordinates is just another name for barycentric coordinates, AFAIK.
Offset coordinates are really painful to work with in hex grids, trust me. Should be fairly easy to convert from axial to offset once the hard calculus is done, though.

from tiled.

bjorn avatar bjorn commented on May 5, 2024

Well, I know offset coordinates and am familiar with the issues it causes with the editing tools in Tiled. However, as I said this mode needs to be supported for backwards compatibility. Of course it would be nice to support axial coordinates as well, and it looks like this system will work better with the existing tools. Though, I'm sure it will also need changes to things like line and circle drawing and of course the terrain tool, in order to work perfectly.

from tiled.

bjorn avatar bjorn commented on May 5, 2024

For reference here are the forks I'm aware of that merged @maq777 hexagonal renderer with more recent versions of Tiled:

@evant took that version and merged Tiled 0.6, 0.7, 0.8 and 0.9 into it:

https://github.com/evant/tiled/branches/hex

And here's another version by @chedburgh that rebased the commits on top of a more recent version of Tiled:

https://github.com/chedburgh/tiled/commits/master

from tiled.

go3k avatar go3k commented on May 5, 2024

I find a alternative way to build a hexagonal map using tiled map editor without any changes, my own practice is:

  1. My hexagon tile size is 128 * 64
  2. New map, set the tile size to 32 * 32
  3. New tileset, set the tile size to 128 * 64
  4. That's all, β€œThis tile editor is wonderful!”

map screen shoot:
tilemap

I create a test repo, hextiletest

from tiled.

bjorn avatar bjorn commented on May 5, 2024

@go3k Ah, that's creative!

from tiled.

cristaloleg avatar cristaloleg commented on May 5, 2024

@go3k looks cool, but this is hack. i think users needs real support for hextiles

from tiled.

Mungoid avatar Mungoid commented on May 5, 2024

@Goutte - Thats a fantastic link! I originally wanted to use tiled for my map but i just decided to roll my own in 3d and that link provides a great amount of detail! Definitely helped me figure out some aspects of hex tiling =-D

from tiled.

anissen avatar anissen commented on May 5, 2024

Any update on this issue?

from tiled.

bjorn avatar bjorn commented on May 5, 2024

@anissen Nope, sorry. I've been trying to focus on getting a Tiled 0.10 release out for the past weeks. It has such a huge amount of new features that I don't really want to delay it further... on the other hand this is one of the main features still missing to make Tiled more complete. :-/

from tiled.

anissen avatar anissen commented on May 5, 2024

Thanks for your reply. It's perfectly understandable that you want to focus on finishing 0.10. I'm looking forward to it πŸ‘
That being said, there's clearly a big interest in having hexagonal support in a future version of Tiled. Keep up the good work.

from tiled.

tr37ion avatar tr37ion commented on May 5, 2024

@bjorn Great to hear you are about to finish 0.10. I hope, you find the time to add hexagonal tiles later on. I guess, implementing hexagonal tiles is quite complicated, because those tiles can be asymmetric of width and hight. Beginning with evenly sized hexagonal tiles would be a great start.

from tiled.

bjorn avatar bjorn commented on May 5, 2024

@tr37ion Actually 0.10 is out since a week now!

As for hexagonal, I don't think the tile sizes will be problematic, it's more that hex needs additional rendering parameters. But maybe I will just support one variation at first.

from tiled.

gregorth avatar gregorth commented on May 5, 2024

+1 about priority of that feature.

from tiled.

pgolebiowski avatar pgolebiowski commented on May 5, 2024

+2 about priority of that feature. One from me and another from a friend of mine :)

from tiled.

BenjaminFarris avatar BenjaminFarris commented on May 5, 2024

+1 priority. Also I might have some time to help out . ping me if you'd like the help

from tiled.

bjorn avatar bjorn commented on May 5, 2024

@BenjaminFarris Thanks for the offer but I'm currently unsure what to ask help with. For me it's currently mainly a problem of getting around to it. In fact somebody has offered to sponsor this feature a few days ago, making it the first thing on my list. I will try to get this done in the next week.

Once in there will be hex-specific improvements that could be made to the tools. Things like line drawing, copying regions or the fill tool do not work correctly on staggered maps currently.

from tiled.

bjorn avatar bjorn commented on May 5, 2024

I've recently pushed my work on hexagonal map support to master so the daily builds include support for this now, at least two variations of "pointy top" hexagonal. Give it a try!

One caveat is that currently a new hexagonal map will start out looking pretty much the same as staggered isometric. It is only after you increase the "Tile Side Length" in the map properties that it will start to appear hexagonal (since by default the length of the side is 0).

I hope to get around to adding support "flat top" hexagonal later this week, and I'm also considering to add support for "hexagonal isometric", which would be a variation of the isometric renderer but with a hexagonal grid.

from tiled.

bjorn avatar bjorn commented on May 5, 2024

Adding support for "flat top" hexagonal took way longer than I had anticipated. The main issue with it was that it meant staggering the X axis, which required a rather different way of rendering to keep the tiles in the correct order. I also did not find a nice way to share code like grid drawing, layer bounding boxes and converting screen position to tile position. But, it's now finally done and pushed as 915fd32.

So, there is no support for "hexagonal isometric" yet, which I still hope to add later, but I consider this issue closed. The one problem with having to discover the "tile side length" property in the Map properties also remains, but I'll try to solve that later as well. Finally I'll also have to update the documentation about the new properties and how they affect the rendering.

from tiled.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.