Skip to main content

Module coords

Module coords 

Source
Expand description

Coordinate systems of the campaign map.

The campaign map uses three related coordinate systems:

  • World: the f32 positions stored in startpos Coord2d nodes.
  • Raw: the u16 units stored in the map files (trade_routes.ptd). raw = world * scale + 4.
  • Cell: the logical hex grid of the map (HEX_MAP_DATA, 1016x720 cells in Attila’s main map). A cell is 6 raw units wide and 8 raw units high, and odd columns are shifted half a cell down.

The scales of a map (MapScale) come from its hex grid and its size in world units: the last column starts at the map’s right edge, and the last row of odd columns ends at its bottom edge. Characters placed on cells land exactly where the current game build (the one BOB uses) puts them: 518 of 518 in Attila’s main campaign. CA’s older build of the shipped startposes rounds the horizontal position differently, one ulp away at most.

Structs§

EdgePiece
A piece covering some edges of a hex cell (a road or a coast), as a shape and a rotation.
HexCell
A cell of the logical hex grid of the campaign map.
MapScale
World units per raw unit of a campaign map, horizontally and vertically.

Constants§

CELL_RAW_HEIGHT
Raw units per cell, vertically.
CELL_RAW_WIDTH
Raw units per cell, horizontally.
HEX_EDGES
Edges of a hex cell.
RAW_OFFSET
Offset added to raw coordinates.