Can Defold handle hex based maps

#1

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!

0 Likes

#2

There is no built in hex grid support but you can create it yourself using the standard components. @selimanac and @Dragosha are doing this: https://twitter.com/selimanac/status/1198565538676523011?s=19

1 Like

#3

Oh, I’ll fix this!

0 Likes

#4

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


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

3 Likes

#5

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

0 Likes

#6

Which link was broken?

0 Likes

#7

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 https://defold.com/faq/ and it was near the bottom of the post. Seeing as its vanished now, I am guessing that perhaps its specific to new users?

0 Likes

#8

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.

3 Likes

#9

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)

2 Likes

#10

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)

and

https://www.mathopenref.com/coordpolycalc.html

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!

4 Likes