Notes about programming

Images and Data

The map and counters are images - terrain and force are the data

Map coordinates are used to record terrain data. Counter identifiers are used to store force data.

Hexagon map

The wargame map has a hexagon overlay. Hexagons are used for movement and combat. Hexagons have names associated with them to identify their location for movement. The hexagon name is not a coordinate. The hexagon name is converted into a Hexagon Point for wargame calculations. Terrain information is stored in a database with the hexagon point. The Hexagon Point is calculated using Hexagon Grid Technology.

Hexagon Grid Technology

Hexagon Grid is a set of algorithms to calculate the hexagon coordinates from the screen coordinates.

Mouse events

Mouse events on the battlefield are transformed into wargame commands.

Programming Notes

 

Hexagon grid coordinate system

THERE IS NO PRACTICABLE COORDINATE SYSTEM USING HEXAGON NAMES!!!

If you go to HexagonGrids from Red Blob Games, you will find numerous coordinate systems for hexagon grids.

They are trying to create a coordinate system from the hexagon names. This is impractical when calculating geometry.

There is only one workable coordinate system. It is the Cartesian coordinate system from geometry.

Hexagon Grid using hexagon coordinates

Draw a horizonal line thru the hexagon centers and draw a vertical line thru the hexagon centers. This is a workable coordinate system.

This coordinate gives the accurate position on the map or screen.
 
Multiply the coordinate by the x interval (3/4 hexagon width) and the y interval (1/2 hexagon height) .
 
Since this is a real coordinate, all the math and functions of Analytical Geometry work!

There is no need to calculate for offset odd-even columns.

to move N: 0,-2
to move NE: +1,-1
to move SE: +1,+1
to move S: 0,+2
to move SW: -1,+1
to move NW: -1,-1

Bonus: There are some very useful math algorithms for range, direction, line of sight using the grid numbers.

 

Hexagon Grid using hexagon and hexside coordinates

Draw a horizonal line thru the hexagon/hexside centers and draw a vertical line thru the hexagon/hexside centers. This is workable coordinate system if hexsides need to be located.

There is no need to calculate for offset odd-even columns.

to move N: 0,-4
to move NE: +2,-2
to move SE: +2,+2
to move S: 0,+4
to move SW: -2,+2
to move NW: -2,-2

Bonus: There are some very useful math algorithms for range, direction, line of sight using the grid numbers.