Documentation ¶
Overview ¶
Package genmap2d implements... <drumroll...> a simple 2d map generator!
Index ¶
Constants ¶
View Source
const ( TileIDGrass byte = iota TileIDWater TileIDTree TileIDSand TileIDMountain TileIDSnow TileIDVillage TileIDMax )
Various tile IDs.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Map ¶
type Map struct { Width int // Width of the map Height int // Height of the map Villages []*VillageScore // Generated villages Elevation []float64 // Elevation values for each cell Cells []byte // Cells contains the assigned tile IDs Rand *rand.Rand // Rand initialized with the provided seed Noise opensimplex.Noise // Noise initialized with the provided seed }
Map represents a generated map.
func (*Map) GetCoordinates ¶
GetCoordinates returns the x and y coordinates for the given index.
func (*Map) PlaceVillage ¶
func (m *Map) PlaceVillage()
PlaceVillage calculates the suitability score for each point on the map and will add a new village that gets the optimal score while being as far as possible from other villages. TODO: Factor out suitability function.
func (*Map) TileFromHeight ¶
TileFromHeight returns the tile ID for a given height.
type VillageScore ¶
Click to show internal directories.
Click to hide internal directories.