Making Hexagon Maps

Does anyone have any recommendations for tools or resources that could help with making the sort of hex map used in traditional war games?

Unfortunately, I think you'll be faced with writing your own hexagonal output system for Corona. The "Lime" module supports the "Tiled" map editor, but I don't think Tiled handles hexagonal tilemaps (only rectangular and isometric, and Lime probably doesn't do isometric yet). Anybody want to clarify or correct this statement?

Regardless, I don't think it would be that difficult to write a hexagonal output sequence. The hexagons obviously fit together with some mathematical formula (which I don't know offhand). You could then create your worlds using big Corona arrays (tables nested in other tables or whatever). Or you could write a routine to read data from a text file or XML file, which is what Lime does. The levels in my current in-progress game are all constructed from data in text files, which is carefully parsed and re-assembled for the device screen.

Hopefully this is a start... best of luck!

Damn! Well, this is like 6 months too late, but I wrote a little tutorial on this subject!

http://www.iswdev.com/?p=39#more-39

Hope it helps, holler if I can answer any questions!

Best,
Mario

For Hexagons, or any polygons I use SVG Level Editor (not free), I think it cost me 49 bucks? Its a Level builder.

You use SVG inkscape and draw things out and it codes into corona. So if you do things like bezier curves (a pain in my ass normally, but EASY on svg level ed), or things like polygons etc its very nice.

What you are looking to do is a hexegon map I assume, so you could easily do that. You would just use the polygon tool and then draw them and line them up, probably using alternate colors and make it as big as you want and use that as a template.

Of course, you would have to implement some touch dragging on the map if you make it bigger than the screen...etc etc.

You can read more about it here: http://karnakgames.com/wp/

it's either that or you will have to create each point of the hexagon, and .....that makes my head hurt lol.

Thanks, Mario. That's very helpful. Now I just have to work out distance calculation, pathfinding, and line of sight.

Glad to help out!

I've never used A* ever, but I *imagine* since it's still a 2D array we're comparing against, pathfinding should be easy?

Distance....hmmmmm. Lemme know what you come up with, we'll add it to that tutorial so others can enjoy!

Hey mroberti,

Just caught this discussion. Fantastic example using Corona! I did something exactly like this for the iPhone a few years ago and is was painfully slow do to inefficient re-drawing of the png files each time the map needed to be updated. Even limiting the program to only draw hexes onscreen wasn't very efficient either. I finally settled on using Cocos-2d for iPhone because it handled off-screen buffering and a few other tricks that were unknown to me. Have you found that this code is fast and dynamic while scrolling around the screen for large (x > 20 & y > 20) maps?

Thanks for the replay in advance, very neat example!
Austin McElroy

views:1914 update:2011/10/4 8:06:35
corona forums © 2003-2011