Documentation
¶
Overview ¶
Package hmz2map emits the game engine's hex map. Its exported types are the map's JSON schema: the engine and the map converters import them.
Index ¶
- Constants
- Variables
- func Build(g hmz2ele.Grid, doc *hmz2bio.Document, rivers *hmz2riv.Rivers, opt Options) (*Map, Report, error)
- func Neighbor(col, row int, s Side) (int, int)
- func RenderPreview(m *Map, apothem, scale int) (image.Image, error)
- func Validate(m *Map) error
- func Version() semver.Version
- type Biome
- type Corner
- type Depth
- type Flag
- type Hex
- type Kind
- type Landform
- type Map
- type Options
- type Placement
- type Report
- type River
- type RiverSize
- type Side
- type Source
- type Summary
- type Surface
Constants ¶
const ( ShallowElevation = -5 OpenElevation = -50 DeepElevation = -500 InlandSeaElevation = 0 )
Salt-water elevations, in meters, by depth band. Inland seas are at sea level, and border hexes are deep.
const ( RiverMinKm2 = 250 GreatRiverMinKm2 = 2000 )
Size class breaks, in km² of real ground. An area exactly on a break takes the larger class.
const BorderWidth = 4
BorderWidth is the width, in hexes, of the border that the -border flag adds. It is even, so the border keeps every column's parity.
const Layout = "flat-top, 0-based, odd columns down"
Layout describes the map's coordinates.
const SchemaVersion = 1
SchemaVersion is the version of the map's JSON layout. It changes when a change to the layout would break a reader.
Variables ¶
var Biomes = []Biome{ BiomeClear, BiomeTundra, BiomeAlpine, BiomeDesert, BiomeScrubland, BiomeGrassland, BiomeSteppe, BiomeSavanna, BiomeBorealForest, BiomeTemperateForest, BiomeTemperateRainforest, BiomeTropicalDryForest, BiomeTropicalRainforest, BiomeCloudForest, }
Biomes lists every biome, in the terrain model's order.
Corners lists every corner, clockwise from east.
var Depths = []Depth{DepthShallow, DepthOpen, DepthDeep}
Depths lists every depth band, shallowest first.
var Flags = []Flag{FlagCoast, FlagRiver, FlagVolcano, FlagInlandSea, FlagImpassable}
Flags lists every flag.
var Landforms = []Landform{ LandformFreshWater, LandformSaltWater, LandformFlats, LandformPlains, LandformRollingPlains, LandformHills, LandformMountains, LandformPlateaus, LandformVolcanicHighlands, LandformCliffs, LandformBadlands, }
Landforms lists every landform, in the terrain model's order.
var RiverSizes = []RiverSize{SizeStream, SizeRiver, SizeGreatRiver}
RiverSizes lists every size class, smallest first.
Sides lists every side, clockwise from north.
var Surfaces = []Surface{ SurfaceClear, SurfaceGlacialIce, SurfaceMarshes, SurfaceSwamps, SurfaceBogs, SurfaceMangroves, SurfaceSaltFlats, }
Surfaces lists every surface, in the terrain model's order.
Functions ¶
func Build ¶
func Build(g hmz2ele.Grid, doc *hmz2bio.Document, rivers *hmz2riv.Rivers, opt Options) (*Map, Report, error)
Build emits the map of a climate document and its rivers. It doesn't validate the result; see Validate.
func Neighbor ¶
Neighbor returns the hex across the given side of (col, row). Odd columns are pushed down half a hex. The result may be off the map.
func RenderPreview ¶
RenderPreview draws the map with hmz2bio's preview, on the map's own layout, with hexes apothem pixels tall. Rivers are drawn from the hexes' river lists.
hmz2ele's grids shift even columns down, so map column c is drawn as column c + 1 of an hmz2ele grid; the empty column 0 is cropped off.
Types ¶
type Biome ¶
type Biome string
Biome is a hex's ecology.
const ( BiomeEmpty Biome = "" // unset BiomeClear Biome = "clear" BiomeTundra Biome = "tundra" BiomeAlpine Biome = "alpine" BiomeDesert Biome = "desert" BiomeScrubland Biome = "scrubland" BiomeGrassland Biome = "grassland" BiomeSteppe Biome = "steppe" BiomeSavanna Biome = "savanna" BiomeBorealForest Biome = "boreal-forest" BiomeTemperateForest Biome = "temperate-forest" BiomeTemperateRainforest Biome = "temperate-rainforest" BiomeTropicalDryForest Biome = "tropical-dry-forest" BiomeTropicalRainforest Biome = "tropical-rainforest" BiomeCloudForest Biome = "cloud-forest" )
type Flag ¶
type Flag string
Flag marks a feature that combines with a landform.
const ( FlagCoast Flag = "coast" // land next to salt water, or salt water next to land FlagRiver Flag = "river" // land with a river on at least one side FlagVolcano Flag = "volcano" // from the hand-made list FlagInlandSea Flag = "inland-sea" // salt water in a body cut off from the open sea by a narrow strait FlagImpassable Flag = "impassable" // cliffs, badlands, and land along a border cut )
type Hex ¶
type Hex struct {
Col int `json:"col"`
Row int `json:"row"`
Landform Landform `json:"landform"`
Surface Surface `json:"surface"`
Biome Biome `json:"biome"`
Depth Depth `json:"depth,omitempty"`
Flags []Flag `json:"flags,omitempty"`
// Elevation is in meters.
Elevation int `json:"elevation"`
// Rivers lists the hex's sides that carry a river, in side order.
Rivers []River `json:"rivers,omitempty"`
}
Hex is one hex. Depth is set on salt water only.
type Landform ¶
type Landform string
Landform is a hex's underlying physical geography.
const ( LandformEmpty Landform = "" // unset; an error in the map // Water. LandformFreshWater Landform = "fresh-water" // lakes LandformSaltWater Landform = "salt-water" // seas, including inland seas // Land, by relief. LandformFlats Landform = "flats" LandformPlains Landform = "plains" LandformRollingPlains Landform = "rolling-plains" LandformHills Landform = "hills" LandformMountains Landform = "mountains" LandformPlateaus Landform = "plateaus" LandformVolcanicHighlands Landform = "volcanic-highlands" // Impassable by normal means. LandformCliffs Landform = "cliffs" LandformBadlands Landform = "badlands" )
type Map ¶
type Map struct {
SchemaVersion int `json:"schema_version"`
Hmz2mapVersion string `json:"hmz2map_version"`
Layout string `json:"layout"`
Columns int `json:"columns"`
Rows int `json:"rows"`
// Border is the width, in hexes, of the decorative deep-ocean band
// around the map: 0 or 4.
Border int `json:"border"`
// HexKm is a hex's flat-to-flat size, in kilometers.
HexKm float64 `json:"hex_km"`
Sources []Source `json:"sources"`
Climate Placement `json:"climate"`
// Hexes lists every hex, ordered by row, then column: hex (c, r) is at
// index r × Columns + c.
Hexes []Hex `json:"hexes"`
}
Map is the hex map, as written to JSON.
type Options ¶
type Options struct {
// Border is the border's width in hexes: 0 or BorderWidth.
Border int
HexKm float64
// ClimateFile and RiversFile are the input files' base names.
ClimateFile, RiversFile string
}
Options are the settings of a map.
type Placement ¶
type Placement struct {
TopLatDeg float64 `json:"top_lat_deg"`
BottomLatDeg float64 `json:"bottom_lat_deg"`
}
Placement is the climate step's placement: the latitudes of the source raster's top and bottom edges, north positive.
type Report ¶
type Report struct {
// Kinds counts the map's hexes by kind.
Kinds [3]int
// CliffsFilled counts the cliffs and badlands with no median, and
// CliffPasses the passes needed to give them an elevation.
CliffsFilled, CliffPasses int
// DepthChanges counts the source hexes that would get a different depth
// band if their distance were recomputed over the map.
DepthChanges int
// EdgesTouching counts the river edges listed on fill and border hexes,
// by kind; EdgesOffMap counts the edges with a hex off the map.
EdgesTouching [3]int
EdgesOffMap int
}
Report counts what Build did beyond copying hexes.
type River ¶
type River struct {
Side Side `json:"side"`
// Flow is the corner of this hex that the water flows toward.
Flow Corner `json:"flow"`
// DrainageKm2 is the area of real (source) ground draining through the
// edge.
DrainageKm2 float64 `json:"drainage_km2"`
Size RiverSize `json:"size"`
}
River is a river along one side of a hex. The same edge is listed by the hex on its other side, from that hex's point of view.
type Side ¶
type Side string
Side is one of a flat-top hex's six sides.
type Source ¶
type Source struct {
FileName string `json:"file_name"`
Tool string `json:"tool"`
Version string `json:"version"`
}
Source identifies an input file and the tool that wrote it.
type Summary ¶
type Summary struct {
Landforms, Surfaces, Biomes, Depths, Flags, RiverEdges map[string]int
// LandMin and LandMax are the lowest and highest land elevations.
LandMin, LandMax int
}
Summary counts a map's hexes. Surfaces and Biomes count land hexes only, and RiverEdges counts each edge once, by size class.
Directories
¶
| Path | Synopsis |
|---|---|
|
cmd
|
|
|
hmz2map
command
Command hmz2map emits the game engine's hex map from an hmz2bio climate file and an hmz2riv rivers file, as JSON, with an optional PNG preview.
|
Command hmz2map emits the game engine's hex map from an hmz2bio climate file and an hmz2riv rivers file, as JSON, with an optional PNG preview. |