Mapping Terrain
The Hexpart object provides a way to uniquely identify each hexagon center
and hexagon hexside.
This hexpart coordinate can be used to store terrain data in
a database or an array.
In this example, the Terrain object creates a two dimensional javascript array. Since the array is an integer array, the terrain features can be assigned bit-wise numbers. The number for each terrain feature present is added together, and the total is stored in the javascript array.
| 1 | offmap |
| 2 | clear |
| 4 | rough |
| 8 | road |
| 16 | town |
| 32 | forest |
| 64 | river |
For storing the terrain data in a database, the primary key would be autonumber and the
data would store the x, y coordinates and one of the terrain features
for example:
| primary key value | 4 | 8 | clear |
| primary key value | 4 | 8 | road |
| primary key value | 6 | 10 | clear |
| primary key value | 8 | 16 | rough |
| primary key value | 8 | 20 | clear |
| primary key value | 8 | 20 | forest |
| primary key value | 6 | 14 | clear |
| primary key value | 6 | 14 | town |