G
Guest
I have been developing a little project which draw's a hexgrid on a panel
within a form similar to this - it:s used as a client from a e-mail based
strategy game:
____ ____
/ \ / \
/ (0,0) \____/ (2,0) \____/
\ / \ / \
\____/(1,1) \____/ (3,1) \_
/ \ / \
/ (0,1) \____/ (2,1) \____/
\ / \ / \
\____/(1,2) \____/ (3,2) \_
/ \ / \
/ (0,2) \____/ (2,2) \____/
\ / \ / \
\____/(1,3) \____/ (3,3) \_
The number of hexes can vary depending on the mapsize. now the problem I
currently have is trying to get a label.text to display which hex coord the
mouse is currently in.
Using the mouse move function I can get it to automatically change when it
passes over the lines in the (1,y) columns by using the following formula:
(for these purposes HexHeight = 44 pixels, HexWidth = 50 pixels)
MouseYpos = LocalMousePosition.Y / HexHeight
Label1.text = "Coords: " & MouseXpos & "," & MouseYpos
however, because the colums are staggered any column starting with an even
number get's the new coords changed halfway through it.
So I'm now leaning towards trying mark the centre point of each hex, and
then establishing which one the mousepointer is nearest to. However I'm
having difficulty in figuring out how to do this.
Can anyone help?
within a form similar to this - it:s used as a client from a e-mail based
strategy game:
____ ____
/ \ / \
/ (0,0) \____/ (2,0) \____/
\ / \ / \
\____/(1,1) \____/ (3,1) \_
/ \ / \
/ (0,1) \____/ (2,1) \____/
\ / \ / \
\____/(1,2) \____/ (3,2) \_
/ \ / \
/ (0,2) \____/ (2,2) \____/
\ / \ / \
\____/(1,3) \____/ (3,3) \_
The number of hexes can vary depending on the mapsize. now the problem I
currently have is trying to get a label.text to display which hex coord the
mouse is currently in.
Using the mouse move function I can get it to automatically change when it
passes over the lines in the (1,y) columns by using the following formula:
(for these purposes HexHeight = 44 pixels, HexWidth = 50 pixels)
MouseYpos = LocalMousePosition.Y / HexHeight
Label1.text = "Coords: " & MouseXpos & "," & MouseYpos
however, because the colums are staggered any column starting with an even
number get's the new coords changed halfway through it.
So I'm now leaning towards trying mark the centre point of each hex, and
then establishing which one the mousepointer is nearest to. However I'm
having difficulty in figuring out how to do this.
Can anyone help?