Detecting polygons

Detecting polygons

Detecting points, lines and 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

map  

 

 

 

 

 

 

 

Screen coordinate

The hexagon coordinate for unit counter placement (along with circle/rectangle detection):

        Hexagon


Wargame coordinates:

        Hexagon

        GridPoint

        Edge

        Circle

        Rectangle


Terrain data:

       x,y,terrain
       6,46,'Road'
       8,48,'Road'
       10,46,'Road'
       12,44,'Road'
       12,40,'Road'
       12,36,'Road'
       14,38,'Road'
       16,40,'Road'
       18,38,'Road'
       20,40,'Road'
       20,44,'Road'
       20,48,'Road'
       20,52,'Road'
       18,34,'Road'
       16,32,'Road'
       16,28,'Road'
       16,24,'Road'
       16,20,'Road'
       16,16,'Road'
       16,12,'Road'
       16,8,'Road'
       8,16,'Clear'
       12,20,'Clear'
       16,16,'Clear'
       16,48,'Clear'
       16,40,'Clear'
       16,32,'Clear'
       16,24,'Clear'
       12,44,'Clear'
       8,48,'Clear'
       20,44,'Clear'
       24,40,'Clear'
       24,48,'Clear'
       24,16,'Clear'
       20,20,'Clear'
       24,24,'Rough'
       20,28,'Rough'
       24,32,'Rough'
       20,36,'Town'
       20,44,'Town'
       8,24,'Forest'
       12,28,'Forest'
       8,32,'Forest'
       12,36,'Forest'
       8,40,'Forest'
       18,18,'River'
       18,22,'River'
       18,26,'River'
       18,30,'River'
       18,34,'River'
       18,38,'River'
       20,40,'River'
       22,42,'River'
       22,46,'River'
       28,12,'Offmap'
       28,20,'Offmap'
       28,52,'Offmap'
       28,44,'Offmap'
       28,36,'Offmap'
       28,28,'Offmap'
       20,52,'Offmap'
       12,52,'Offmap'
       8,56,'Offmap'
       16,56,'Offmap'
       24,56,'Offmap'
       4,52,'Offmap'
       4,4,'Offmap'
       4,12,'Offmap'
       4,20,'Offmap'
       4,28,'Offmap'
       4,36,'Offmap'
       4,44,'Offmap'
       8,8,'Offmap'
       12,4,'Offmap'
       12,12,'Offmap'
       16,8,'Offmap'
       20,4,'Offmap'
       20,12,'Offmap'
       24,8,'Offmap'
       28,4,'Offmap'
       20,36,'Road'