Skip to main content
gamedev.net
🔒 Locked

Drawing a Hexagonal map

Started by Daichi Feb 15, 2004 at 11:49 PM 5 replies 1.2k views
Original Post
Daichi
Daichi
I''ve been looking online but I haven''t seen much on the topic. How would I go about drawing a hexagon with line tools, more specifically a hexagonal map with various properties such as the height, width, on its side? And after having drawn this map, how would I find the map coordinates on this map? Most of the information I found was for using tiles. Any ideas? -Daichi
Daichi
Daichi
Well, it took me several hours of googling, but I finally found this website on plotting a regular hexagon...

http://www.rdwarf.com/~wwonko/hex/

Now any math wizzes wanna show me how I can change the angle, width, and height of this formula?

Wargame-Programming.com had another formula for using a staggered square; can someone clarify this process for me?

http://wargamer2.tripod.com/wargames/

-Daichi

Doctor J
Doctor J
What is the actual problem that you are running into? Are you having trouble drawing even a single hexagon? Or are you asking about drawing multiple hexagons at proper offsets to create a full map of hexes? Are you useing a full screen background image and just need to draw hexes on top of it? Or are you actually using hexagonal tiles?
Daichi
Daichi
I am currently not using tiles, and I don''t think I will end up using them on this project. In my first post I did specify I am drawing a Hexagon with basic line tools.

Right now I''m most worried about the math that goes into ploting a non regular Hexagon that tesselates into a Hexagonal Grid. I figured out how to draw a regular Hexagon just fine, I guess I didn''t clarify that in my 2nd post very well.

If you take a look at MapDraw 3.1 on the Wargame-Programming website, you can set Hex Dimensions; The Angle, Width, and Height. This is exacly what I would like todo for my program.

Anyway, hope that helps clarify.

-Daichi
Doctor J
Doctor J
OK now I understand better.
For the sake of discussion, consider a bounding rectangle around the hexagon. The rectangle has a height of "H" and a width of "W". Let us refer to the top left of the rectangle as coordinate (0,0). The top vertex of the hexagon will be at the middle of the top of the rectangle; (W/2, 0). Similarly, the bottom vertex of the hexagon will be at the middle of the bottom of the rectangle; (W/2, H). Now there are four more points of the hexagon to determine. They are all related by symmetry considerations. We can describe them with another parameter called "a". The four remaining hexagon vertices are: (0, a), (0, H-a), (W, a) and (W, H-a). "a" is, of course related to the angle at the top and bottom vertices. "a" can range from 0 to H/2.

You can specify those three values (H, W, a) and draw a hexagon. To draw a row of hexagons, skip over by "W" and repeat the process. To go down one row, move down by "H-a" and over by "W/2".
Doctor J
Doctor J
Well, this topic piqued my interest... I wrote a simple program in Delphi to draw hexes and perform the "mouse-mapping" (which is somewhat confusing.) Here is the program and the source code:
Hex Test

[edited by - Doctor J on February 18, 2004 10:31:33 PM]
Daichi
Daichi
Hey, I haven''t had much time todo any programing recently, so I''m slowly getting back into it. Thanks for your help, I think the only problem I''m going to have is figuring out the mouse coords, but I think I can figure it out with the help of that source if I put my brain into it all. ^^; If I have any problems I''ll be back.

-Daichi

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.