Can Defold handle hex based maps


G’day, Im looking at making a computer version of a board game as an inexperienced C# programmer. Its probably too big a task for me, game engine or no - twelve months ago I started working on making business logic in C# and learned a lot about the language I didnt know, but didnt actually get it working.
Im looking at Defold and Id like to take another crack at this project using Defold, but Im curious about whether Defold can handle the hex based map Ill need to use for this game. I was using a library to handle the hexes when I last had a go at this project, but Im not sure that would work with Defold.

I did have a look at the FAQs mentioned above to see if there was anything in them about grids, but unfortunately the link is broken!



There is no built in hex grid support but you can create it yourself using the standard components. @selimanac and @Dragosha are doing this:

1 Like


Oh, I’ll fix this!



AFAIK you should be able to create anything yourself with game components.

This is a very good read about implementing a hex grid.



It is! Thats the library I was using in my earlier efforts on this project, actually.



Which link was broken?



Its disappeared now. It was pinned to the top of the forum, below the current announcement, welcoming me to the forum and suggesting I read the FAQs before posting.

The link was to and it was near the bottom of the post. Seeing as its vanished now, I am guessing that perhaps its specific to new users?



Hex grids are not the something related to engines. It is just a logic. You can use hex grids almost every engine.
I’m using Tiled to edit the grid for now. You can simply export and parse the json file.
It isn’t so hard to parse the json but Tiled coordinate system is different than Defold, you should consider this.



tiled is free and it’s really, REALLY useful for this sort of thing. I used it for my grid-based game (exporting lua tables). And, yes, it would be easy to create a hex grid (it’s basically a square grid but every other row is offset by 0.5, it’s not something crazy)



I’ve been experimenting with Hex grids in Defold lately as well. I am NOT strong in math, or in code, and I’ve managed to get a working prototype complete with some basic A*

2 Resources I can not recommend enough:

for basically everything related to layout and coordinates of the hex grid (I used the “cube coordinates” method detailed here, flat-top version)


used to create the actual tile sprites, as well as the custom .convexshape collider

I have each tile as a game object with the custom collision shape, for mouse-over detection. There may be a better way, but this suits me fine.

edit sorry, didn’t notice the redblob site was already linked! oh well! it’s a great resource for this in any case!