I'm desperately looking for help regarding the following:
I need to make a hexmap in it's own scrollable window on a form, when I
say hex map I mean a graphical hexagon surrounded by other hexagons the
same size. The program I'm writing imports region information i.e 10,13
would be a hexagon, 10 hex columns to the right and 13 hex rows down
from hex 1,1.
I have some source code for a Delphi add-in but having had zero
experience with Delphi, it's not a good place to start.
Can anyone point me in the right direction?
Please...
Niels
The "easiest" solution would be based upon what you want to do with it.
If it is just draw a hex picture map, you could just create a cell block and
tile it. But not of much use.
If you want "intelligence", then you should probably go the vector route and
create hex cell Objects that render themselves to an intelligent "hex grid"
control.
Like most things, there are numerous ways to do this, but "begin with the
end in mind" to get the best results.
Gerald
"Niels Jensen" <st...@surf-spot.co.uk> wrote in message
news:hMGdnVANL4S...@pipex.net...
Dim myHexagon(8) As Point
Dim clientArea As Graphics
myHexagon(0) = New Point(50, 10)
myHexagon(1) = New Point(60, 10)
myHexagon(2) = New Point(70, 20)
myHexagon(3) = New Point(70, 30)
myHexagon(4) = New Point(60, 40)
myHexagon(5) = New Point(50, 40)
myHexagon(6) = New Point(40, 30)
myHexagon(7) = New Point(40, 20)
myHexagon(8) = New Point(50, 10)
clientArea = Me.CreateGraphics
clientArea.DrawLines(New Pen(Color.Red), myHexagon)
--
OHM ( Terry Burns )
. . . One-Handed-Man . . .
If U Need My Email ,Ask Me
Time flies when you don't know what you're doing
"Niels Jensen" <st...@surf-spot.co.uk> wrote in message
news:hMGdnVANL4S...@pipex.net...
> Do you want to be able to graphically select hex cells?
Yup - this will definitely be handy as that way you could click on a hex
and see which units are in it
> Do you want to draw something else contained with the cells?
Yes again - each hex will have different terrain features such as
mountains or desert. Each hex can also contain thins like towns or
player built buildings
> Do you want all sides to be equal like a regular circular inscribed polygon?
> Or could the height/width aspect ratio be different?
All sides equal would be best
> Is the master grid a fixed size, or you want it to be dynamic?
> Would the grid be rotatable?
Rotating isn't necessary, zooming in and out however would be a benefit
but not necessarily needed
> What dotNet drawing methods are you familiar with?
Here's the problem :) - next to nothing - yet. But with the help of the
net and other reference material I tend to pick these things up v.quickly
>
> The "easiest" solution would be based upon what you want to do with it.
> If it is just draw a hex picture map, you could just create a cell block and
> tile it. But not of much use.
> If you want "intelligence", then you should probably go the vector route and
> create hex cell Objects that render themselves to an intelligent "hex grid"
> control.
>
> Like most things, there are numerous ways to do this, but "begin with the
> end in mind" to get the best results.
>
> Gerald
Thanks Gerald - you've definitely given me things to think about. now
to start looking for the material i need :)
Niels
> This is simple a vector drawing is it not, you could create an array for
> each hexegon containing Six Points, these co-ordinates are then used to draw
> a path on the graphics area of your control/form.
>
> Dim myHexagon(8) As Point
> Dim clientArea As Graphics
>
> myHexagon(0) = New Point(50, 10)
> myHexagon(1) = New Point(60, 10)
> myHexagon(2) = New Point(70, 20)
> myHexagon(3) = New Point(70, 30)
> myHexagon(4) = New Point(60, 40)
> myHexagon(5) = New Point(50, 40)
> myHexagon(6) = New Point(40, 30)
> myHexagon(7) = New Point(40, 20)
> myHexagon(8) = New Point(50, 10)
>
>
> clientArea = Me.CreateGraphics
> clientArea.DrawLines(New Pen(Color.Red), myHexagon)
>
Thanks for this, very kind of you - it'll give me someplace to start my
research - btw that's an octagon - a hexagon has six sides ;)
Niels
One thing that will require special consideration is how you want to define
rows.
Since of course a Hex Grid zig-zags instead of being a classic grid.
Take a look at the attached 2 pictures.
In HexMap1, you have a defined set of rows. However, this is going to be a
mild pain to deal with the offsets. This is probably how the game works.
In HexMap 2, you have a mathematically easier approach, however your row
definition gets a little weird. If you are on an Odd Column, then your Rows
would be Odd. If on Even Column, then your Rows would be Even.
How does your game deal with this?
Gerald
"Niels Jensen" <st...@surf-spot.co.uk> wrote in message
news:hZqdncHDdd7...@pipex.net...
> I'm giving this some thought.
> To get everything you want might be quite complicated. Especially when just
> learning.
> However, that is half the fun, and what better way to learn, right?
> I may be over complicating this, but I think you might want to create a user
> control that will render everything. To accomodate the zooming and location
> functions, your best bet would be to treat these cells as vector objects.
> Meaning real Hexagons, instead of simple brush tiles.
This does sound more complicated - but I'm a firm believer that if you
dive in at the deep end you'll always end up with what you want - minus
a few handfuls of hair :)
So, I take it using vector objects is quite a bit more complicated than
Terry Burns solution?...
>
> One thing that will require special consideration is how you want to define
> rows.
> Since of course a Hex Grid zig-zags instead of being a classic grid.
> Take a look at the attached 2 pictures.
> In HexMap1, you have a defined set of rows. However, this is going to be a
> mild pain to deal with the offsets. This is probably how the game works.
> In HexMap 2, you have a mathematically easier approach, however your row
> definition gets a little weird. If you are on an Odd Column, then your Rows
> would be Odd. If on Even Column, then your Rows would be Even.
>
> How does your game deal with this?
The game has the following description in it's rules - The game's called
"Atlantis":
----
Since Atlantis is made up of hexagonal regions, the coordinate system is
not always exactly intuitive. Here is the layout of Atlantis regions:
____ ____
/ \ / \
/(0,0) \____/(2,0) \____/
\ / \ / \ N
\____/(1,1) \____/(3,1) \_ |
/ \ / \ / |
/(0,2) \____/(2,2) \____/ |
\ / \ / \ W-O-E
\____/(1,3) \____/(3,3) \_ |
/ \ / \ / S
/(0,4) \____/(2,4) \____/
\ / \ / \
\____/ \____/
/ \ / \
Note that the are "holes" in the coordinate system; there is no region
(1,2), for instance. This is due to the hexagonal system of regions.
---
So it would seem that any hexes with an even column will only have even
rows and likewise any odd column hexes only have odd numbered rows. It
helps knowing that a map will never use negative numbers so a simple
mathematical equation should be able to work out how to place the hexes.
I can also provide an example on how the report processes it's region
information. As it stands, my basic program at the moment is able to
process the reports and categorize them into relevant groups. I'm
thinking of using ADO to store the turn information, this will allow me
to use SQL to filter out specific region information for each hex.
Niels
Actually, the vector method will essentially be the same as OHM's
suggestion.
But instead of drawing just 1, you would just write formulas to build the
whole grid.
There are many ways to derive the numbers for the points, but in the end you
will just pass an array of points to draw the Hex cell.
I'm giving the overall grid some thought and how that will work with
scaling.
Drawing 1 is easy, but making it interactive is more fun.
My suggestion is to deal with a "grid" where you know the center of the Hex
cells.
Then derive the polygon points from the center point.
This way you would also know where to draw other cool things in the middle
of the cell. ;-)
Gotta run at the moment, but I'll throw up a couple of formulas when I get a
chance.
Gerald
"Niels Jensen" <st...@surf-spot.co.uk> wrote in message
news:HOadnUT16OF...@pipex.net...
--
OHM ( Terry Burns )
. . . One-Handed-Man . . .
If U Need My Email ,Ask Me
Time flies when you don't know what you're doing
"Niels Jensen" <st...@surf-spot.co.uk> wrote in message
news:RLCdnesPG-6...@pipex.net...
Thanks for all your help so far, you're an absolute star.
I can't seem to find the attachement anywhere - I've checked using buth my
mail client and Microsoft's newsgroups site and cant find a link to get hold
of it. It was the same with the previous attachements you posted.
Any way I can get hold of them?
Niels
"Gerald Hernandez" wrote:
> Ok, I took the time to put together an intro to Hexagons and Drawing
> project, attached.
> Take a look at it. Hopefully, it is fairly self explanatory. You should
> notice the basic hexagon code is pretty simple. Essentially variations on
> OHM's (Terry Burns) suggestion. I included 2 slightly different ways to get
> the points for the hexagon, but many more methods could be derived as well.
>
> Overall, the project is very simple.
> Draws a single hexagon in the center of a "graphics" area. I arbitrarily
> picked a Panel Control.
> Also shows a couple ways to deal with size, and automatically refreshing the
> drawing.
> Disclaimer: This doesn't represent "best practice" coding, just a simple
> sample. In the end, I recommend you wrap up the whole HexGrid into a class
> and eventually a user control. But you have a long way to go before then.
>
> Of course, this does not address the "grid" issue along with a ton of over
> things. But take a look at what there is so far and digest that. It might
> get you jump started on the rest of the project. Or at the very least, it
> might help you develop a list of questions to get you to the next step.
>
> Gerald
>
>
> "Gerald Hernandez" <Cablewizard@spam_remove@Yahoo.com> wrote in message
> news:uYIz6iRm...@TK2MSFTNGP10.phx.gbl...
Then try checking the message again.
Otherwise, email me your email address at Cablewizard@Spam_Remove@Yahoo.com
by removing the @Spam_Remove part, and I will try mailing to you directly.
Gerald
"Niels Jensen" <Niels Jen...@discussions.microsoft.com> wrote in message
news:40D1C186-1F8C-41D2...@microsoft.com...