map

As the mouse moves over the battlefield map

3 map coordinate points are identified and the hexagon name      is calculated.


1. Grid point: As the mouse moves across a hexside, its location is recorded by a bounding rectangle. The hexside rectangle is drawn on the map in blue for the demo. The center of the hexside is found on the hexagon grid and stored as

   grid point  

If the mouse is not on a hexside, the hexagon center is recorded. Certain terrain types, such as roads, have their location placed on hexsides and the connecting hexagon center between hexsides.

The grid point rectangle is used to calculate when the mouse moves over the hexside line and calculate the hexagon point.

Note: The detection of the hexside usually generates a lot of discussion. Where does the hexside start? Where does the hexside end? The use of a bounding rectangle is a 'good enough' compromise.


2. Hexagon point: As the mouse move across a hexagon, its location is recorded. The hexagon is drawn on the map in red for the demo. The center of the hexagon is found on the hexagon grid and stored as

  hexagon point  

To calculate if the mouse is in a hexagon, the blue rectangle of the GridPoint is analyzed to see if the mouse has crossed over the red line.


3. Vertex point: As the mouse moves across a hexagon corner, its location is recorded by a bounding square. The corner square is drawn on the map in green for the demo. If the bounding square is not on a hexagon corner, no location is recorded. The reference hexagon is found on the hexagon grid and stored with a direction as

   vertex point  


All coordinates are based on the cartesian coordinate system.

Using the hexagon coordinate, the actual location of the hexagon center on the map
can be calculated at to place counters on the map.

To draw the hexagon, draw lines to the following points:

The hexagon name is not a coordinate. It is calculated from the hexagon point.

Programming Notes

 

Mark Butler
Copyright © 2016