Voronchuk / hexagons / Hexagons.Map

This module solves the problem of generating and storing the Map data. We are using Elm dictionary as the Map storage engine with Hex coordinate tuple as the key.

See http://www.redblobgames.com/grids/hexagons/implementation.html for reference.

Types


type alias Map =
Dict Hash Hexagons.Hex.Hex

Dictionary storage to keep map of hexes


type alias Hash =
( Basics.Int, Basics.Int, Basics.Int )

Hash key to access Map cell

Accessing map storage

hashHex : Hexagons.Hex.Hex -> ( Basics.Int, Basics.Int, Basics.Int )

Hash function to get a uniform token to address stored hex Hex

getHex : Hexagons.Hex.Hex -> Map -> Hash -> Hexagons.Hex.Hex

Fetch hex from map storage, using a default value in case of missing Hex

Map generators

rectangularPointyTopMap : Basics.Int -> Basics.Int -> Map

Generate Map of rectangular shape given its height and width

rectangularFlatTopMap : Basics.Int -> Basics.Int -> Map

Generate Map of rectangular shape given its height and width