Detecting polygons
Calculating grid coordinates
As the mouse moves over the map, the screen coordinates are converted to 4 grid points uses for calculations. The polygons are calculated for wargame coordinates and 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