Hexagon Shaped Tiles
by Spencer Grey · in Torque Game Builder · 06/27/2006 (8:23 am) · 6 replies
Hey,
Does TGB have any built in stuff for making hex grids? If not, are they playing to implement that in the future?
If not its no big deal, as I can just write an editor that parses out the data, then copy that into tgb ... but that feels a bit excessive. Creating a brand new tile editor to use tgb.
Has anyone else figure out a good way to deal with this?
Thanks.
Does TGB have any built in stuff for making hex grids? If not, are they playing to implement that in the future?
If not its no big deal, as I can just write an editor that parses out the data, then copy that into tgb ... but that feels a bit excessive. Creating a brand new tile editor to use tgb.
Has anyone else figure out a good way to deal with this?
Thanks.
#2
X - 0 - X - 0 - X
0 - X - 0 - X - 0
That creates a hex that is 82 pixels "square" which divides down perfectly for calculating where to load image maps and such. As far as image maps are concerned, you can either display a static sprite at each location, or you can try splicing your images, but I'm not sure how well that'll work with those pixel numbers as they are approximations - very close approximations, but your mileage may very. They fit our needs perfectly. See, we went a slightly different route as we didn't want to display a hex image anyway. We simply display a "chinese checkerboard" type grid...

Hope this helps.
-Andrew
06/27/2006 (10:24 am)
What we do isn't really hex tiles, but we have a tile map with the cell width of 71 and a height of 41, and the center of each hex is the center of every other tile. Like so:X - 0 - X - 0 - X
0 - X - 0 - X - 0
That creates a hex that is 82 pixels "square" which divides down perfectly for calculating where to load image maps and such. As far as image maps are concerned, you can either display a static sprite at each location, or you can try splicing your images, but I'm not sure how well that'll work with those pixel numbers as they are approximations - very close approximations, but your mileage may very. They fit our needs perfectly. See, we went a slightly different route as we didn't want to display a hex image anyway. We simply display a "chinese checkerboard" type grid...

Hope this helps.
-Andrew
#3
I'm in the middle of setting a system up which will dynamically spawn in a series of hex image maps. You pass in the width and height of the thing, and it figures out where to place each image. I'm splitting each hex into two parts -- a border and a fill, since I'll need control over whether or not the hex is open or closed.
Its coming along so far, but the thing that gets me is how to set the properties for each hex. If I could somehow get the sprites to show up in the level editor, then it would be a simple matter of selecting the right datablock for each hex.
It's not as elegant as I'd like, but this is just a test project anyway.
Anyone know if its possible to dynamically spawn something and have it show up in the level editor?
06/27/2006 (10:44 am)
Interesting approach. Unfortunately, I need to display an actual hexgrid :/.I'm in the middle of setting a system up which will dynamically spawn in a series of hex image maps. You pass in the width and height of the thing, and it figures out where to place each image. I'm splitting each hex into two parts -- a border and a fill, since I'll need control over whether or not the hex is open or closed.
Its coming along so far, but the thing that gets me is how to set the properties for each hex. If I could somehow get the sprites to show up in the level editor, then it would be a simple matter of selecting the right datablock for each hex.
It's not as elegant as I'd like, but this is just a test project anyway.
Anyone know if its possible to dynamically spawn something and have it show up in the level editor?
#4
-Andrew
06/27/2006 (11:02 am)
I'm going to duck the question kinda 'cuz what little I've done to dynamically spawn stuff for use in the designer didn't really act quite right at design time.. But anyway, why not use tilemaps then for design time and then load your imagemaps based on the tilemap's custom data? You certainly aren't required to show the tilemap to the player just because you wanted a way to design the maps visually. It should be a simple matter to layout the tilemap, like I said, with skipping every other tile and with a width and height that works for your desired hex size. Sure, it may not look the same between design and run time.. but it should allow a fairly smooth workflow. Note: there are some limitations to the number of static sprites you'll want to create that way, but your map would have to be pretty huge for it to become an issue. If it did become an issue, I'm sure you can split things up so you don't need all the static sprites loaded at once anyway. -Andrew
#5
@Spencer - You could Andrew's system and then just overlay the hex grid.
06/27/2006 (11:09 am)
@Andrew - That seems like a solid aproach for a hex grid.@Spencer - You could Andrew's system and then just overlay the hex grid.
#6
06/27/2006 (11:16 am)
Not a bad idea. I just might do that ;)
Torque Owner Thomas Buscaglia