Detecting polygons
Calculating grid coordinates from polygons
As the mouse moves over the map, hexagons on the map are detected. The screen coordinates are converted to a point. These points are used for calculations.
Once the polygons are calculated for wargame coordinates they are never used again.
The purpose here is to use the mouse to assign map elements with a coordinate. For example, if a unit is moving across the river from 0302 (16,24) to 0402 (20,28), the wargame would check for a river in the terrain database with a mid-point coordinate of (18,26).
Grid coordinates are calculated for wargame map features.
Grid coordinates are used to draw graphics on the wargame map.
Polygon detection example
Screen coordinate
The hexagon coordinate for unit counter placement (along with circle/rectangle detection):
Hexagon
Wargame coordinates:
GridPoint
Edge
Circle
Rectangle
Terrain data:
x,y,terrain